I'm working on a suite of Selenium WebDriver (not Selenium RC and not using Selenium-Server) tests that are being executed by a command-line call to MSTest. I've broken them into test classes for each browser we plan on testing (Chrome, Firefox and IE9, for now) and each test class has a startup method that logs in to the system under test and then executes the test(s) requested and a TearDown method that closes the browser using WebDriver.Quit().
On my development machine everything is hunky-dory, but on our build machine the class initialization/start-up method executes fine and logs into the site, but as soon as the first actual test starts the test runner closes with the error message:
OpenQA.Selenium.WebDriverException: Unexpected error. System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 127.0.0.1:59982
obviously the port changes depending on which browser's being tested; when I run the whole suite I get errors on different ports for the tests for IE, Firefox, and Chrome - two errors for each browser (as the suite currently has two tests for each browser)
Windows Firewall is off for the build machine, and checking netstat before running the tests shows that the port's not in use; if I debug the tests and stop after the startup code runs but before the test runs, of course the port is in use. 127.0.0.1 and localhost are the same as well.
I get the same error whether or not I call the test via the command line, run/debug it from within Visual Studio using the VS Test tools, or by executing my console app, which calls MSTest via Process.Start(). The exception is thrown on the first FindElement() call.
Where can I start looking to figure out why this is failing on the build machine and not on my dev box?
The issue here was that in trying to implement some more robust error handling during startup I place a call to the Teardown code in the finally block of a try/catch wrapped around the login code, so as soon as the test harness was done logging in I was closing and cleanin up the WebDriver instance, so when the test ran there wasn't a WebDriver there to communicate with.
I suspect when I as looking at the "same" code on my dev machine the libraries that were actually running didn't have that block in them.
When you run an application from Visual Studio it fires up a server listening on a certain port. In your case 59982.
You need to actually have your web application running on its own on the test environments before running your test against it.
On your dev machine your application is running on that port. I'm guessing on your remote machines that is not the case.
Related
I connect remote windows server in Jenkins by node&slave concept and I create a "freestyle" job and run batch command in Jenkins in that command I wrote selenium scripts. the job was working fine.
When a test fails it takes a screenshot of the browser window. Unfortunately, the browser is always a fairly low resolution: 1024 x 656.
If I run the tests manually within the VM (logging in and running them outside of Jenkins) then they're run at the desktop resolution of the login.
So, my question: how can I set the screen resolution that is used when the tests are run by the Jenkins Service? Is this possible?
So the concept is like this -
I would like to run the selenium server .jar file on a remote windows machine.
Then connect to it via the default port (:4444), open browser and navigate to a URL of my choosing.
I have everything working except the part of running the selenium server through robot.
This keyword works as far as I can tell (until the open browser keyword) -
Start Selenium Server
&{client} = Return Internal Host
Connect Environment Machine Windows ${client}
start process java -jar ${/}SeleniumServer${/}selenium-server-standalone-3.141.59.jar alias=seleniumserver
process should be running seleniumserver
open browser http://example.com/example.html chrome None http://1.1.1.1:4444/wd/hub
BUT, when I try to connect to the selenium server I get the following error -
"No connection could be made because the target machine actively refused it"
It seems like the process either does not run or runs for a short amount of time then closes.
What am I missing here?
If I manually start the server on the client, everything works. It opens the browser and does whatever I need. (manually running the java -jar selenium*.jar on the cmd)
But when I run this Start process keyword, that should keep the process running in the background, I get connection refused. Any Ideas?
Another piece of information that might be useful - The selenium server should throw an error if trying to run it twice on the same machine (because of the used port bind 4444).
When running the keyword shown above, while there is a selenium server up and running on the target machine, the test still passes for some reason. Not sure if it is even running the process as intended but the "process should be running" keyword seems to pass.
Thanks!
I have a Selenium automation suite up and running with chrome which works like a charm. I have integrated IEdriver within. After integrating I executed few of the test cases and getting problem with the execution on IE11. I observed that my test fails with the exception "HTTP request to the remote WebDriver timed out after 60 seconds" . This behavior is random for every run and in continuing tests, pop up window is always logged out in application. Did anyone face similar problem?
You could maybe increasing the timeout?
InternetExplorerDriver driver = new InternetExplorerDriver(#"c:\pathtoie", options, TimeSpan.FromMinutes(2));
I was doing development and test execution on VM and whenever I lock my system, the script hangs on the VM. So doing execution on a VM from different VM will solve the problem.
I have a GoCD server that I plan on running my selenium test suite on. This machine is a Linux machine. So.. I set up selenium on a windows machine. The key problem I am having is that when running as a service, or a scheduled task, the selenium hub does not launch IE.
If I remote desktop into the machine, run the jar manually from command line, the browser launches in my RDP session and the tests all pass. If I install it as a service (With permissions to interact with the desktop!) the driver appears to run, but the content never loads.
So if you have an answer, please remember:
The grid works for all browsers with an interactive desktop session open.
Without an interactive desktop session, Chrome and Firefox tests still pass (in headless mode).
I am using no selenium nodes, I am only using the standalone jar (not running as hub or node, just running the tests standalone.
I am using version 3.14 of both selenium standalone and IEDriverServer.exe
I know that tons of people do automated IE tests with selenium, but how do they do it with Hub on windows?
I've tried literally every options setting I can see to try to phinigel a way to get it to work, but it's just not having it.
I also tried running as a scheduled task rather than a service, no dice there either.
This is the precise error the IETests are presenting:
Oct 09, 2018 1:15:12 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
org.openqa.selenium.TimeoutException: Expected condition failed: waiting for value to contain "sign-in.host.com". Current value: "null" (tried for 10 second(s) with 500 milliseconds interval)
at org.openqa.selenium.support.ui.WebDriverWait.timeoutException(WebDriverWait.java:113)
at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:283)
I used to have issues with IE selenium tests on a VM in azure. What i noticed was that while RDP to the machine everything worked fine but when i closed the session all tests failed.
What i ended up doing was leaving a logged in console session after every RDP closing.
After adding a trigger on session log off i run a powershell script with the following:
Tscon 1 /dest:console
This keeps an active desktop session and my tests on IE pass.
We have a CI setup using bamboo where one job was to run our automation, it checks out our Automation Solution from a repository, and run it using NUnit runner where it contains tests using selenium webdriver and some unit tests. It runs unit tests(not using webdriver commands) just fine, but not the webdriver tests.
We are sure that the solution is being checkout correctly because we can run the test using the command line referencing the created local repository, including tests that uses webdriver using the command below:
C:\pathToNUnitConsole\nunit-console C:\pathToCreatedLocalRepositoryInTheServer\NUnitTest.dll -include=FirefoxBrowserTest
We can see that the bamboo job never launched a browser, and we are getting test failure for not seeing browser elements. Also, we are getting error as we see in the logs:
10-Apr-2015 13:19:49 http://10.215.12.28:15871/cgi-bin/blockpage.cgi?ws-session=587410860
10-Apr-2015 13:20:42 JavaScript error: resource://gre/modules/CertUtils.jsm, line 168: NS_ERROR_ABORT: Certificate issuer is not built-in.
I don't know if this is your problem, but it sounds very similar to an issue I had trying to get NUnit runner to run tests built in SpecsFor.MVC, which is a wrapper that deals with instantiating an IIS Express instance, deploying a target web application to known location, then using Selenium/Chrome Driver to run the tests against the web app.
The problem I had was trying to run the Bamboo remote agent as a windows service. The Local Service account was not able to access the interactive desktop. Also, changing the service to run as a specific user account still failed, as the service was not allowed access to the user's isolated Session0.
I could login as that test user and run the test from the command line no trouble, but I couldn't get it to run when initiated by the remote agent windows service.
I eventually fixed it by using AlwaysUp (not a plug. I'm sure other similar solutions are available). This allowed me to set the machine running the tests to always log in as the test user on startup, would automatically restart the bamboo remote agent if it was closed for some reason and most importantly, to give the service access to the user's isolated session0.
Hope that might give you a few clues...