ChromeDriver throws JVM Bind Exception - webdriver

im encoutaring some wierd behaviuor with the ChromeDriver on Selenium 2.0.
i have a test suite that consists of about 20 tests.
when i run the test individualy, they all work fine. both on firefox and chrome.
though when i run the entire suite on chrome i get a JVM Bind Exception telling me the address is already in use.
the thing is that the first 2-3 tests pass, and it only happens after them.
maybe OS is having trouble recycling processes?
the suite works perfectly on firefox...
any ideas?
i use window xp 32bit OS.
thanks

try calling "webDriver.quit()" method after the end of each test. Selenium 2 is known to have this bug of exhausting the ephemeral ports, and the above piece of code should get some relief. I tried it, and it does close some ports.
Thanks,
Prakash.

Related

Every time I use expo client, my http network fails to work

TCP connections work fine as I am able to converse with someone over zoom and teamviewer. However, whenever I attempt to access another webpage, I get a network error. Google seems to work fine for some reason but any webpage I go to listed by Google fails to connect. The only way I can open up my http connections is by ending a task called "init" inside of task manager. This shuts down my vscode as well as my ubuntu terminals I have running. If someone knows the solution please do tell. It's really annoying having to close out my vscode and terminals as well as my local servers to look up information and debug.
I found a fix to this issue.
So I was running a Windows Subsystem for Linux and my Windows Build was outdated as well as WSL. When I updated Windows and upgraded to WSL2, my issue was resolved and I don't seem to get any more network errors.

When does System.out not appear in the Java console?

I understood that anything to standard out (System.out) would appear in the Java Console window (when it's enabled). I spotted somewhere though that there might be situations where this isn't try, for example, from Swing apps. Is that the case?
Basically, what situations or setups wouldn't I expect to see standard output in the console? Is there a difference in behavior running on the JDK rather than explicitly on the JRE for example? javaw.exe?
ps, I understand how to display the Console in the Java settings but I'm curious as I've managed to create an application, run as an executable jar, that doesn't start the console despite some calls to System.out) on Windows 7.
The only way you wouldn't see System.out output in the console is if the method System.setOut has been invoked. This method is invoked to redirect output to the graphical Java Console, but I don't know of any other realistic circumstance in which it would be redirected away from the Java Console unless you do so voluntarily.
Depending on terminal settings it can happen that the output is not written until a newline character is sent as well. So if you do System.out.print("test") it might not appear immediately.
On Windows this is usually not the case, but on Unix terminals this is quite common.
Perhaps you use javaw to start virtual machine, this version will not show console messages. You can use java to start the virtual machine, which will show the console message.
javaw is intended for apps with windows, java is intended for console apps.
Same thing happened to me. I could not get System.out.println or Logger.debug either on console.
If you are on a huge project in Eclipse or whatever, you can read below.
Solution: I realized that I had not committed jars and some java files to SubVersioN on network. thats all. Project had not been compiled.
One situation I can think of is to invoke System.setOut(null) (orSystem.setOut(any OutputStream other than System.out or System.err)) then the console, if exists, would show nothing.

Chromedriver is extremely slow on a specific machine using Selenium Grid and .net

Overview:
Chromedriver works normally on one machine but extremely slowly on two other identical machines.
Setup:
Selenium Webdriver using .Net for coding and Selenium Grid for distributing the tests. MSTest is being used from within Visual Studio 2010 in order to run the tests.
A 64bit Windows 7 local machine acting as the Hub
Three 32-bit Win 7 remote machines (two of them are virtual) on my local network all configured as nodes. Here is the command used to start the nodes on the remote machines:
java -jar c:\seleniumWebDriver\seleniumGrid\selenium-server-standalone-2.31.0.jar -role node -hub http://XXX.XXX.XXX.XXX:4444/grid/register -browser "browserName=chrome",maxInstances=4 -Dwebdriver.chrome.driver="C:\seleniumWebDriver\chromedriver.exe"
The driver is launched like this from within the code:
DesiredCapabilities capability = new DesiredCapabilities();
capability.SetCapability(CapabilityType.BrowserName, browser);
driver = new RemoteWebDriver(new Uri(hubUrl), capability);
The variable "browser" and "hubUrl" above is passed via an app.config file that is built at runtime. For this case, browser=chrome.
Problem:
When I setup machine 212 (which is a virtual machine) as a chrome node using the command above, and then launch the scripts from the hub, I see chrome start in the proper remote machine and run normally. It fields between 5-10 commands per second.
When I setup either machine 78 (virtual machine) or machine 103 (real machine) as a node in the same manner, and then launch the scripts from the hub, I see the node start up chrome properly. However, it runs extremely slowly, like 1 command per sec or less.
Other info:
Like I said, on one machine chrome works normally, but on the others, runs extremely slowly. Firefox and IE, when configured as nodes, work normally.
I have compared the machine 212 (which works properly) with the other machines and cannot find the difference. All the machines are using 'selenium-server-standalone-2.31.0.jar' and the same version of the ChromeDriver.
It does not appear that the node machines are being overloaded. Also, it is a very consistent difference in performance which does not seem related to any fluctuating load on the network or the machines.
My network tech has verified that all these machines are configured identically on the network.
Has anybody seen anything like this before?
EDIT 1: I logged in today and all three remote machines are running chrome slowly. Before one of them was normal, but now they are all slow.
I ran into a similar issue where chromedriver was slow in some machines and it turned out to be a proxy issue. Disabling "Automatically detect settings" under Chrome://settings >Change proxy settings> LAN Settings> made webdriver execute commands faster in chrome for me.
My proxy settings were not using automatic detection, but I found the following helped a lot. The time it took to start the driver went down from 43 seconds to 1 second
driver = new ChromeDriver(new ChromeOptions{Proxy = null});
Bug link in chromedriver issues This is long lasting issue that got lowest priority. But as more user will vote for it maybe someone will fix it. It could also be releated to Parsing of proxy configuration is not standard compliant which will be fixed soon.
This code solved the problem for me for Chrome 75 on macOS 10.14.3
ChromeOptions options = new ChromeOptions();
options.setProxy(null);
driver = new ChromeDriver(options);

Selenium performance with .NET and Jenkins - How to profile and improve it?

I have an ASP.NET website that I want to test with Selenium. I want to setup a Jenkins instance on a "staging" virtual machine, to run the tests automatically.
The problem is that the tests run very slowly - several times slower than on my development machine. A single, simple test can take more than 2-3 minutes.
I'd like to know if this is to be expected, if there are any obvious pitfalls for such a testing setup as mine, and if there's anything I can do to profile and improve the performance of the test suite.
Info:
Tests run on a 2.7GHz 2GB Ram virtual machine with Windows 7 64bit.
My dev machine is similar, but with a 32-bit Win installation.
The following is done by Jenkins:
The website gets checked out from source control, and configured with a custom web.config. The main differences are that it's compiled in release mode and it connects to a database on a different machine(also a virtual machine, on the same server).
IIS is monitoring the website's directory and automatically reloads changes.
The following command is run (directories sanitized): nunit-console Selenium-Project-Dir /labels
The tests are run on the Chrome webdriver.
The selenium project uses NUnit and WebRunner.
Driver instances are created once - before all tests, in a [SetUp] attribute inside a [SetUpFixture] class. They are deleted once, in the class's [TearDown] attribute.
A sample test looks like this:
[Test, Combinatorial]
public void AnExistingUserCanLogin(
[ValueSource(typeof(Drivers), "Good")]
IWebDriver driver)
{
// This function clicks on some buttons and fills in some forms.
LoginUser(driver);
// Make sure the user is now logged in
Assert.IsTrue(driver.ElementIsPresent(By.ClassName("imgUserAvatar")));
Assert.IsTrue(driver.ElementIsPresent(By.CssSelector("a.my-profile")));
Assert.IsTrue(driver.ElementIsPresent(By.CssSelector("a.logout")));
}
(The "Drivers" class contains lazily-instances webdriver instances of FF, IE, Chrome. You can guess what the "Good" static property of the class instances)
The fact that it is a VM should not be a problem, and RAM sounds like it is good. What OS is being run though? Some of the Windows OS have significant speed differences between the different bit versions (because of demands on hardware). This is especially noticeable in Vista but I have noticed a difference between Windows 7 and Server 2003.
I have found that there is a huge problem if the machine running the 64bit VM is a 32bit machine. It often seems to work well for a while and then as it continues to run tests will slow down. Which should be a duh but the main thing is that there may be too many VMs being run from the same place. Other programs will be affected by this and that can help troubleshoot if your VMs are on a company farm.
The other factor that has made a significant difference is if you are running the tests against different browsers. IE8 and IE9 will take the same selenium command and run them at different speeds. I don't know why this is, I just know that I have seen it. Make sure the staging machine has the current version of Chrome (or at least the same as your dev machine).
How the staging machine is networked to the database might be making a difference. This seems like a very small chance but if there is firewall crap between the two VMs that can have significant impact on time.
The only other thing I can think of that might be changing the length of time is if there are other programs being executed on the on the staging machine at the same time. Checking the CPU usage might helpful. Personally, I have noticed that my VM uses a lot more of the CPU than my personal machine. If this is the case the only solution I have found so far is to give the VM more processing power or to only run the test and nothing else.
Good luck!

Is it possible to run browsers in headless mode in a windows box?

I'm writing tests using webdriver in Java.
Is there a way to run browsers (ff / ie) in headless mode in a windows box?
I cant use a linux box and HtmlUnitDriver is not helping as our webapp has many ajax controls.
I have started a small project to supply a driver for WebDriver using SimpleBrowser. You may want to check it out: https://github.com/Teun/SimpleBrowser.WebDriver
It's still early days though. I would appreciate help in the form of contributions and testing.
At this point there is no headless version that I am aware of the Firefox or IE. Since Firefox is open source it's possible that you could get the source code for that browser and then remove the UI portion but there are a few problems with it that I can see. First you have to build a custom app to setup your own load testing engine. Second you are locked to one web render, though I think chrome is open source as well but it doesn't play as nicely as Firefox or IE (using the system .dlls vs. a custom executable). Third without a lot of testing I am sure there will be stability issues and potentially other unforseen issues with this option. That being said there is a .net headless browser that's fairly simple and would probably be decent for load testing called simple browser. However it depends on what you are wanting to load. If you just looking for bandwidth and server load then you should be find using multiple instances of the browser. I would be curious to know if using the headless browser in this fashion if you instantiated different WebDriver if it would play nicely. i.e.
WebDriver driver1 = new SimpleBrowser();
WebDriver driver2 = new SimpleBrowser();
.
.
.
.
.
WebDriver driver[n] = new SimpleBrowser();
and then you could run [n] parallel tests. Also of note in the above code SimpleBrowser() doesn't hook directly to the WebDriver interface you would have to Extend the interface to reference that .dll
Start the test program as a Windows service and the browsers will run just fine, even on a machine with no monitors. Technically speaking, they're running in a "session" that is disconnected, but it's essentially what you mean by "headless".
HtmlUnitDriver does support ajax, and can run in both java and c# (if ported via IKVM).
There is, however, no way to run IE and FF in headless mode. I can't tell you how many times I've wished for that...

Resources