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
Related
We have ~150 e2e tests and executing in multiple browsers like chrome, firefox, IE, Edge & Safari. Few tests are failing on different reasons. Is it possible to execute only failed tests using protractor?
Yes, You can use protractor-flake => https://www.npmjs.com/package/protractor-flake
It's able to rerun whole spec files. You actually can provide a parser which receives all test output. We use this and it's very helpful.
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 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
I want to use the protractor to run the tests on the selenium grid, which runs on :
http://<ip_address>:4444/
In my config file I have:
seleniumAddress: "http://32.14.98.73:4444/wd/hub",
When I run the test, they are run locally and start the browser on the local system. ? Anything else is needed for this to work ?
In logs I have:
[18:20:05] I/direct - Using ChromeDriver directly...
[18:20:05] I/launcher - Running 1 instances of WebDriver
Change your config file for object directConnect to directConnect:false. For detailed understanding on directConnect and seleniumAddress refer the below link Difference running Protractor with/without Selenium?
I am running Jmeter with the Webdriver plugin installed on Windows 7. My current test plan contains the Webdriver sampler and Firefox driver config. When I try to run the test plan, nothing happens. There is nothing recorded in the View Results Tree window, and the remaining test indicator in the top right hand corner counts down to 0 without anything happening.
When I deactivate the Webdriver Sampler and Firefox driver config elements, the remaining tests run without a problem.
Is there a bug with this software, or am I missing something? My code is below, if that helps.
var pkg = JavaImporter(org.openqa.selenium)
WDS.sampleResult.sampleStart()
WDS.browser.get('https://test.test.test.test') var username =
WDS.browser.findElement(pkg.By.id('USERNAME')).sendKeys([WDS.args[0]])
var password =
WDS.browser.findElement(pkg.By.id('PASSWORD')).sendKeys([WDS.args[1])
WDS.sampleResult.sampleEnd()
I have installed firefox 26, as this is the recommended supported browser, so it's not that there's no compatible browser.
My main question is this - Why doesn't the browser window open? Why do the other tests in the test plan fail to run when the config elements are active?
In 99% of cases the answer should be in jmeter.log file. In the meantime a couple of recommendations:
add the following line to system.properties file (lives in the /bin folder of your JMeter installation)
webdriver.firefox.bin=/path/to/your/firefox.exe
See https://code.google.com/p/selenium/wiki/FirefoxDriver page for other Firefox-related properties
locate all duplicate http* libraries like httpcore*.jar httpmime.jar etc. and remove the ones with lesser version
restart JMeter to pick the property and the changes up
Check out The WebDriver Sampler: Your Top 10 Questions Answered guide for other tips and tricks
You need to make sure you provided the full path of the Firefox driver in the jp#gc config element.