Multiple selenium webdriver instances using Internet Explorer 11 interfere with eachother - c#

I have the following situation, I have two test cases running in parallel that each open a selenium webdriver instance for Internet Explorer 11 and both navigate to the same login page and both try to login with a different username/password combo. The problem is that both webdrivers seem to get stuck during username input for some reason.
I should mention that running either test by themselves works without issue, running both tests sequentially is also ok, so the problem only occurs when both tests are ran at the same time.
Also of note is if I try the same thing with two instances of Chrome Driver instead of Internet Explorer, again there is no problem. So this is something related to the IE webdriver and only when there are multiple instances of it at the same time.
Does anyone have any solution/idea that could solve this?

It has already been documented here as a known issue, and currently the only way to reliably do this using IEDriver is by using separate vms.

Related

Selenium c# : How to work with manually opened browser using selenium c#

I would like to debug test scripts when ever failed. I dont want to run the entire test script from startng onwards (launching browser..logging )
If my browser already opened (manually) and I would like to click on some objects (Web) , how can I achieve this programatically using selenium. I can do this in QTP but I dont know how can achieve this in selenium. Appreciate your quick help. !!
I am using Selenium 3.3 & IE 2.53 driver for Internet explorer
In general, the answer is that you can't do this. WebDriver explicitly does not support attaching to an existing browser instance that it did not start. This is a general principle, but is also explicitly true for Internet Explorer. I know that's not the answer you wanted to hear, but that's the way the IE driver is written at present.
I have faced similar problems. I work with an applications that has more than 10 screens.
We came up with a solution where we did not closed the browser if we encounter any failure. Have a solid exception handling in place and do not call Close() or Quit() methods to close the browser session.
Refer the below to come up with the program to continue automation with the already opened session. This is pretty much possible depending on how you designed your Automation framwork.
How to use a already opened firefox for testing in Selenium
Work on firefox for debugging purposes and then you can run the same test with Internet explorer
Note : I will update the answer with C# program to work with existing browser instances.

Firefox WebDriver randomly not actually executing clicks

Our Selenium tests were developed in C# and were running just fine for months but recently we noticed that a number of tests started failing when executed with Firefox WebDriver.
After investigating the test results and executing tests locally we noticed that from time to time clicks on random elements are executed (we can tell because the visual state of the button or the link changes to what looks like a clicked element)
Browser console does not indicated any errors. WebDriver logs show that click was executed.
Will be grateful for any help.
Edit:
Version of Selenium WebDriver - 2.53.0
Versions of Firefox - (tried few) 33.0.1, 43.0.1, 45.0, 46.0.1
Firefox scale 100%
tried with native events on and off
tried with additional implicit waiting before click
You question is not very specific, so I'll try to offer possible ways you can choose to resolving it.
You didn't indicate which driver and browser versions you used. If you didn't observe failures for months ant suddenly they appeared, my first guess would be that FF version you use on test machine(s) got updated (or driver version in tests was changed), and new combination can work differently. I had situation like this when tests behavior changed, updating driver version helped.
Another option would be to try and see which webelements get misclicked more often than others and insert instructions that check if they are displayed before executing actual click.
Also, try to do step-by-step debugging (if you haven't already) and see if you observe wrong clicks then
One thing we've seen in our testing is that if we're clicking around on the VM while a Selenium test is running on our VM, it can actually prevent clicks from going off.
But another thing we've encountered is that the clicks are often not working where they should be, so you can counter this by using JavaScript clicks instead of Selenium.
For elements that fail regularly, switch the element.Click() to a method utilizing the code below:
IJavaScriptExecutor executor = driver as IJavaScriptExecutor;
executor.ExecuteScript("arguments[0].click();", ElementToClick)
So the problem was that click does not work even when clicking manually so we'll be investigating in that direction.

Capturing URL while Selenium Tests run

i am automating using selenium webdriver and C#. Is there a way to capture all urls that my browser navigates to while my Selenium automation tests run using an external tool such as Fiddler core / wireshark. I mean while my tests continue to run, I would like some of these tools to capture my urls parallely so that incase my tests fail, i could investigate further by using the final few urls(from the point of failure) to debug the issue.
Is this really possible. Do I need to use a separate thread to one of these tools(Fiddler/wireshark/any other tool) to capture the url?
Can this really be done
There are a few options.
Start wireshark (or fiddler) before your Selenium test kicks off. You can do this with a batch file that gets executed in your test setup.
You can utilize a browser plugin for fiddler. IE has one, I'm not sure if there is a comparible plugin for all browsers though. Then you can get Selenium to activate this through the browser...assuming fiddler keeps in the browser window and not open a separate non-browser window that Selenium can't see.UPDATE: Fiddler plugins don't stay in the browser window so this option won't work.
Write some wrapper code that does a driver.Url and stores it into a list. This wrapper code would check to see if the driver.Url is different from the last stored entry in the object and if it is different then it would add it to the list.
All have pros and cons. 3 would give you the most control as your test itself would gather the URL's and maintain a list in code that you can do what you want with. 1 of course would give you the most robust details, depending on how you setup wireshark, and you can profile the entire machine and network experience. 2 is a middle ground where your test still drives it, but the results are separate...but being part of the browser you would have to avoid cleanup after your tests...if you have more tests than one execute at a time this could cause alot of problems...

How to change selenium WebDriver priority from c#?

I'm trying to make my tests run faster on a dedicated server. I've noticed, that normally the tests run sluggishly, but when I increase firefox priority (which by default is lower than normal), they run much faster.
I was looking for a setting in FirefoxDriver which would let me choose process priority, but I can't find one.
Can anyone point me to how to set web driver priorities in selenium?
I disagree with why you are doing this, and I think simply changing the priority is not the way to solve your issue.
There is no API exposed to do this, so you could send a request off to the Selenium developers for this (http://code.google.com/selenium).
Due to this, you will have to change the priority process after Selenium has created a browser session.
You will need to find the process:
var fireFoxProcesses = Process.GetProcessesByName("firefox");
This will return an array of Process objects, however, if you are running one test after another, there should only be one firefox.exe process open. This is my assumption. Therefore, we get the actual process object:
// should only be one, unless you are opening a few tests in concurrently.
var actualFirefoxProcess = fireFoxProcesses.First();
Finally, change it's priority class:
actualFirefoxProcess.PriorityClass = ProcessPriorityClass.High;
I would guess this can get a little unreliable though.
Edit
As for differentiation of a 'user created' Firefox, and one run by Selenium, you can look at the parent process of the firefox processes. That is, what process launched the Firefox process?
No point in copying code, but this solution worked well for me: How can I get the PID of the parent process of my application ...this then gets tricky because a user can launch Firefox multiple ways, but if they are using a shortcut/start menu list item, the parent process will be explorer.
You've not mentioned what solution you are using for running the tests. Whether it's through Visual Studio's Test Runner, NUnit's own GUI, TeamCity, CruiseControl, Jenkins, TFS or some other CI solution, but you'll need to check what launched the Firefox process in order to determine whether it was a "user created" Firefox instance or one from Selenium tests.

Selenium RC/Nunit/Firefox - Browser Crash on Click

I am testing a complex web application using a test framework comprised of C#, Nunit 2.5.10 and Selenium RC 2.24.1 (Switching to WebDriver is not an option unfortunately).
We recently overhauled our application UI/UX, so we have been systematically updating our tests to fit the new version.
Everything has been pretty smooth until we ran into an issue where our browser seems to randomly crash when running certain tests. We use Firefox(Chrome Driver) for testing, but have various versions installed on our test clients from 3.6 to 15.01. The issue seems to be consistently reproducible on all browser versions running on Windows 7 and Windows Server 2008 R2.
When the browser crashes it leaves behind a dialog which remains even after we run our clean up method which kills any open browser sessions in preparation for the next tests. Because this dialog sticks around, it keeps an RC server session alive which causes the next set of tests to hang.
I traced the tests down to the specific actions which are causing the crash, and it seems to always be a click event, but on various buttons within the application, and not always the same one. The buttons have nothing in common except that they all trigger a javascript postback. I was also able to trace one crash to a postback event triggered by a drop down box selection.
Our test framework is fairly complex and we have thousands of tests, so we have resorted to commenting the crashing tests just to keep the rest of the suite running.
We have been unable to simulate the crash with manual testing, even when following the exact path taken by the selenium test.
Any thoughts on what might be causing this, or ways to troubleshoot it would be appreciated.
I've had issues with intermittent failure of Selenium tests caused by the real time protection on Microsoft Security Essentials. For me unchecking Turn on real-time protection in Settings | Real-time protection while I was running tests fixed the issue. Try disabling your anti virus while running tests and see if that solves your problem. Apparently the actions taken by Selenium can be interpreted as virus activity.

Categories