I'm starting to look at Behave to use for BDD, but I've hit a problem. I have a quite few Selenium (Python) tests that I'm already running successfully, but as soon as I use behave I get an error "chromedriver.exe has stopped working".
In my Selenium tests (using pytest and running it from PyCharm), the test looks as follows (which works fine):
def test_open_google():
driver = webdriver.Chrome('C:/temp/chromedriver.exe')
driver.get('http://www.google.com')
I've then created a steps file (as part of the BDD testing), which contains the following:
#when('I open Google')
def step_impl(context):
driver = webdriver.Chrome('C:/temp/chromedriver.exe')
driver.get('http://www.google.com')
From the command line I run "behave" and get the error popup saying "chromedriver.exe has stopped working.
Does anyone know how I can fix this?
It looks like Behave is not compatible with any of the 32 bit webdrivers. I got the same problem when I used the 32 bit IE driver, but it works when I use the 64 bit driver.
Related
It's not a problem and actually is a nice side affect, but it is confusing me.
When I run the test suite via the command line I see IE pop up and the test run.
When I run it with the exact same arguments from the Task Schedular though it doesn't display IE. The test seems to run correctly (I'm getting the expected TestResults.xml so it all looks OK.
Why's this happening though?
The command is:
"C:\Program Files (x86)\NUnit.org\nunit-console\nunit3-console.exe" "Path_to_test_assembly"
P.S. I'm using the .NET version of Selenium with the IE web driver.
Ok, it seems that the problem is with your access to remote machine. Your IE test are running as a background process on that machine, or running on wrong sessionID. It means that there could be more users/accounts, and your test is running on wrong one.
I'm not sure how exactly are you running this, but you could check your session ID's by typing qwinsta in command line on that machine.
If you want it to run properly you should pass this sessionID as a parameter when connecting to remote desktop, for example, if using psexec and your sessionID is 2 than you pass "-i 2" when starting it. It means that it will interact on user with sessionID 2 on that machine.
I have a configuration and tests written that don't work when I pass them through Selenium grid (but work without).
Selenium Tests / JUnit / Eclipse
One Jenkins job that clones the repository and runs the tests
Selenium Grid plugin installed on Jenkins, and all the nodes (Jenkins slaves on Linux with FF) connected to the hub.
Question 1: The Jenkins job for my test suite starts on a slave. Is this correct? Should I start it on master (I tried and got other issues, but at least I would focus on the real problems if I knew what is the correct way to go).
Question 2. I initialize the driver in #Before test. Is this correct?
driver = new RemoteWebDriver(new URL("http://......"), DesiredCapabilities.firefox());
This is where I initialize the firefox driver when not using grid, and it is working.
Question 3. How do I tell Selenium grid to offer me some logs. In all fairness, I have no idea if my tests even attempt to visit the hub.
The last question is regarding the error that I get only when using grid (again, all my tests work fine without).
org.openqa.selenium.WebDriverException: Specified firefox binary location does not exist or is not a real file: /usr/bin/firefox
There are quite a few solutions for the last error that I have googled and tried, without any luck. Being a beginner, I now doubt my configuration.
Thanks for your time.
Ann
Answers:
Question 1
It's not incorrect to run it on a slave. That's perfectly acceptable.
Question 2
You can initialize the driver wherever you want. You can put it in a #Before, a constructor, or even the method. It's all dependent on what works best for you.
Question 3
i'm not sure if you can do this with firefox, but with the chromedriver you can pass arguments like this: --verbose --log-path=/tmp/chromedriver.log \$*
Last Question
I will answer this question by first asking you a question. your grid and nodes are different servers than your jenkins server? If so, then this most likely means that you need to make sure that your firefox executables are under /usr/bin/firefox. If they are, then make sure that they are executable! e.g.: sudo chmod u+x /usr/bin/firefox
Also, you have your RemoteWebDriver initialization masked so i can't see, but make sure that you have the url of your grid, with /wd/hub concat'ed at the end. e.g.: http://selenium-grid:4444/wd/hub
I have a problem with Selenium and can't get it to work.
What I want to do:
A customer of ours sends us a Selenium test case which shall be executed automatically in several locations and the time taken shall be recorded.
We want to use Selenium and Firefox Portable, because we want to make the tests completely independent of any user input and the installed software at the different locations.
So much for the starting conditions ;)
What we did so far:
The first version was completely written in Java, we exported the test case from the customer to Java with the Selenium IDE Plugin -> Export to Java WebDriver.
This cannot be done anymore, because the customer now uses some functions the WebDriver export does not support. And as we don't want to alter the test from the customer, Java export is no longer an option.
So for the first run we are using this command (any variables are set correctly):
java -jar selenium-2.33.0/selenium-server-standalone-2.33.0.jar -port 5555
-firefoxProfileTemplate "Firefox\Data\profile" -log logs\selenium_server.log
-htmlSuite "*firefox" http://localhost:5555 Testsuite.html
logs\results-firefox-%curTimestamp%.html
This starts my preinstalled firefox, not the portable one. On the customers machine, no firefox is started whatsoever, because it is not installed. So I had to provide the path to the firefox instead, using the "custom" htmlSuite:
java -jar selenium-2.33.0/selenium-server-standalone-2.33.0.jar -port 5555
-firefoxProfileTemplate "Firefox\Data\profile" -log logs\selenium_server.log
-htmlSuite "*custom %FF_DIR%\FirefoxPortable.exe" http://localhost:5555 Testsuite.html
logs\results-firefox-%curTimestamp%.html
This does not work, as the Selenium Server cannot execute this command if run under Windows, which we do (see: http://code.google.com/p/selenium/issues/detail?id=3274)
As comment #6 has some diffs, we patched the selenium Server standalone Jar and ran the test again. Now the browser could be started, but the test could not be run. After the first page loaded we get the error "Permission denied to access property 'document'".
A solution here suggests, a user-rights problem could be the cause and you should try the "chrome" htmlSuite (see: https://sqa.stackexchange.com/questions/1453/how-to-fix-permission-denied-to-access-property-document)
So we did:
java -jar selenium-2.33.0/selenium-server-standalone-2.33.0-patched.jar
-port 5555 -firefoxProfileTemplate "FirefoxPortable\Data\profile"
-log logs\selenium_server.log -htmlSuite "*chrome %FF_DIR%\FirefoxPortable.exe"
http://localhost:5555 Testsuite.html logs\results-firefox-%curTimestamp%.html
Notice our "patched" selenium and the "chrome" htmlSuite.
That didn't work, as well.
So, here in short the results:
htmlSuite = firefox: the preinstalled Firefox is used, if installed, not the Portable one. In case, no FF is installed, the test fails altogether
htmlSuite = chrome: the server cannot start the browser, as it tries to set EnvironmentVariables, which is not supported running Windows (see: http://code.google.com/p/selenium/source/browse/java/client/src/org/openqa/selenium/os/WindowsProcessGroup.java#67 lines 67 following)
htmlSuite = googleChrome: Google Chrome Portable can be started, but the Chrome browser cannot find some elements specified by the test, so we cannot use Chrome (altering the test is no option, as stated above)
htmlSuite = iexplore: Internet Explorer starts, but then a JavaScript error appears, referencing a custom Profile created by Selenium, so the test does not work in IE, either
htmlSuite = custom: the Portable Firefox is started (yeehaw), but does not have sufficient rights to execute the test.
You may use a Continuous Integration System like Jenkins, or TeamCity to execute your tests automatically.
we have now decided to support the customer in installing Firefox on the machines to test, so we can use our batchfile without problems.
As for the bug in selenium look here (code.google.com/p/selenium/issues/detail?id=5554#c14), there is a link to a nightly build that does work (at least for us) with Firefox v23, which Selenium 2.33 does not.
Thanks for everyone who contributed, but I think my first approach can not be achieved the way I thought it could :(
I solved this problem.
Visit this link: http://www.townx.org/blog/elliot/dealing-self-signed-ssl-certificates-when-running-selenium-server-firefox
Point 9:
Delete everything in the directory except for the cert_override.txt and cert8.db files.
Hope it helps
I have a set of tests that I've developed using the Selenium IDE in Firefox. Tests run fine and all pass. Now I'm trying to port those over to C# and run the tests for IE using MSTest and selenium-server. Here's the sequence of events:
Run all tests on Firefox via Selenium IDE. All tests pass.
Export tests to MSTest (Nunit export, rename some stuff etc.)
Start selenium-server-1.0.3
Run the tests in VS2008. Selenium setup is: selenium = new DefaultSelenium("localhost", 4444, "*chrome", "http://localhost/theSite/");; note that I can browse to http://localhost/theSite/ just fine.
4a. Confirm test is launching Firefox. Got result:
17:00:30.290 INFO - Preparing Firefox profile...
17:00:33.842 INFO - Launching Firefox...
First test ( waitForText "Login" in control "ctl00_TopNavBar_LoginStatus1") fails. Can't find the control.
if ("Login" == selenium.GetText("id=ctl00_TopNavBar_LoginStatus1")) break;
or
if ("Login" == selenium.GetText("ctl00_TopNavBar_LoginStatus1")) break;
All other tests fail as well -- same reason. Each test has a waitForText at the top.
Tried running the test in *chrome, *iexploreproxy and *firefox. All fail for the same reason.
Tried dumping a screenshot using selenium.CaptureEntirePageScreenshot("c:\\temp\\screenshots\\seleniumSite.png", "background=#FFFFFF"); and the screenshot is just a white bar.
So, my question is, how do I go about debugging this and figuring out what the real problem is? Clearly the page will render and the tests will pass. It's just when I try those tests in Selenium-RC that it fails so badly. Does the Selenium IDE have some bugs related to exporting tests to C#? (I have noticed one bug).
Are you executing selenium.Start() and selenium.Open()? Do you see the page opened in the browser?
Full initialization should be something similar to:
selenium = new DefaultSelenium("localhost", 4444, "*chrome", "http://localhost/");
selenium.Start();
selenium.Open("/theSite/");
Important Note! test your IDE tests by starting with an empty page. Also, when using the IDE, if a command only has one parameter put it in the Target field, even if it isn't a control name.
IE8 is throwing a slow script error when we try and run the following sahi command (in tests/playback or "evaluate expression"):
_popup("Editor")._click(_image("Menu, _near(_span("Activity"))));
It works in firefox.
http://sahi.co.in/forums/viewtopic.php?id=1970 has the developer's solution if anyone else runs into this. MS Support Article ID: 175500 also describes a registry hack to push back the errors all together.