Is it possible to not shutdown webdriver between two protractor spec execution? - selenium

I would like to run separate protractor specs without closing the browser in between.
Something like:
Open the browser and go to the URL
then, run "protractor conf.js --specs=spec1.js"
then, do some actions on the SUT, typically do some actions on our simulator (so, non protractor actions)
then, run "protractor conf.js --specs=spec2.js"
and finally close the browser and shutdown the webdriver.
The goal is to keep the context between the protractor specs execution.
Is it possible?
Correction and Additional information:
My need is to keep the browser opened between two separate test suites (in separate files) and not between two tests.
I'm using IE11 alongside selenium standalone server.
Thank you.

Protractor by default doesnt close the browser between each session unless you specifically ask it do so. The below option in config file controls that.
/** * If true, protractor will restart the browser between each
test. Default * value is false. * * CAUTION: This will cause
your tests to slow down drastically. */
restartBrowserBetweenTests?: boolean;
Looks like your requirement is
Execute Spec 1
Execute some task outside browser(non-protractor work)
Then Execute Spec 2
Normally how I implement this is - lets say I have a task to validate & confirm email from my outlook , which is a non-protractor task before I run next test case, I just throw an alert at the end of my 1st test case asking the tester to manually verify the email and then accept the alert on the browser and then I will proceed with the second test case

Related

Automatically disable browser cache in chrome while running tests using protractor

I am trying to run tests using protractor but i need to disable the browser cache in order to test some things. I do not want chrome to load the resources from browser cache instead i want it it to send the requests to server and download them. I have tried the following options as part of protractor capabilities but nothing seems to be working,
'--disable-cache',
'--disable-application-cache',
'--disable-offline-load-stale-cache',
'--disk-cache-size=0'```
what if you just run the tests in incognito? that shouldn't save nor reuse the cache
you can do it by passing --headless to chrome args

Starting protractor execution from a selenium session

How can we use protractor with an existing selenium browser session rather than always create a new one. If I have started up a selenium browser session, run some tests in there, and exported the session ID into the environment conf file in protractor or in some other way made it available, it would be nice to be able to configure protractor in the normal way (e.g. using an option in the protractor configuration file) to access this session.
I would need to start a protractor execution in the middle of a selenium execution, do some test, and come back to selenium execution. Something like pseudo-code snippet would really help.
You'll need to session id from the launched browser. You should be able to get it from the http://localhost:4444/wd/hub/static/resource/hub.html. So let's say this session id is '12345', you have two options, you could pass it as a command line or via the configuration file.
command line
protractor protractor.conf.js --seleniumSessionId=12345
configuration file
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
seleniumSessionId: '12345',
...
}
After you have set the selenium session id, you should be able to use the browser session. An example of this being exercised is: https://github.com/angular/protractor/blob/master/scripts/driverProviderAttachSession.js
If you would like to read more about it, I also have a medium post about this feature that I might have worked on: https://medium.com/#cnishina/attaching-a-protractor-test-to-an-existing-selenium-session-931196936ae2

I want to skip tests with the #ignore tag in spec flow

I am running my spec flow feature files with the help of resharper and certain feature files have been ignored for later use with #ignore tag. What happens is that chromedriver opens these tests, realizes that they are ignored and stop the test. As I run the tests from a folder, it takes upto 5 mins for every folder that contain these ignored tests. Is there a way to prevent the test runner,runnning these ignored tests so that I can save some time ?
That really depends on where you are starting chromedriver from. If you are starting the driver in a [BeforeScenario] step then yes. Its as simple as this:
if(!ScenarioContext.Current.ScenarioInfo.Tags.Contains("ignore")){
//start chromedriver
}
in this way you can check to make sure if the current scenario should be ignored or not and avoid starting chromedriver if it is.

Is there console.log output support to terminal/command-line with intern-runner?

I have a dependency with Intern where we have to spin up a Selenium server and use PhantomJS for our tests. We use Jenkins and may need some more inspection/debug output to console but the console.log's get suppressed from the test files to terminal/command-line
Is console.log to terminal/command-line supported yet?
How console.log works with intern-runner depends on where your test code is running. Unit tests (specified with suites) run in the browser, so that's where console.log output ends up. There isn't currently a way to get console output out of a browser for unit tests.
Functional tests (specified with functionalSuites) control a browser, but actually run in Node.js, so output from console.log statements in functional tests generally goes to intern's stdout. The exceptions are log statements in execute and executeAsync blocks; since those blocks run in the browser, that's where the log output ends up. You can retrieve browser logs in functional tests using getLogsFor('browser'), but WebDriver log support is inconsistent between browsers.

How can I stop or pause playframework Selenium tests on error?

I'd like to stop or pause Selenium test when running with playframework, because I can't see what is wrong!
Is there a way to preserve the window with my application on the step where it failed? It automatically closes that window!
You could try a few things after you pin point exactly which step causes the error:
Put a wait command in your selenium test to pause the test so you can see what is going on in the UI
You could start the debugger and put a break point on some code that gets executed on the server after the failure happens (assuming the test continues running after the failure)
You could use the selenium test runner panel to slow down the speed of the test so you can see the error (i.e. I'm referring to the speed slider that you see when you run the tests in the browser via the url http://localhost:9000/#tests)