I am a user of selenium webdriver and I am currently running parallel tests in my automation.I have come to understand that firefox launches from port 7054 when first launching via webdriver.I am running 10 tests at a time and I was wondering if there was some way I could control the port on which firefox browser would be launched example if I wish to launch it from port 7056 when i know another is launching from 7054. Thanks in adavnce
It seems that in theory you could do it with .setPreference(PORT_PREFERENCE, portNumber) on the FirefoxDriver, but in reality you can't change the port due to this bug that causes the default port to always override the port preference.
Unless they fixed it in the past 2 months it seems like you're out of luck; although if you are in a bind, you can grab the Selenium source and apply the fix detailed in that bug report on your own as a temporary workaround.
However, if you are running your tests from different processes, you should be able to specify -Dwebdriver.firefox.port=1234 on the command line to change the port for that particular instance of your program. I have not tried it, but the documentation shows that property.
Related
I am setting up my Appium/TestNG script in java on AWS Device Farm, using the tutorial: http://docs.aws.amazon.com/devicefarm/latest/developerguide/test-types-android-appium-java-testng.html
After I compile and upload the 'zip-with-dependencies.zip' to AWS Device Farm and run the tests on a device, I get an error, that the first clickable element in the script could not be found.
So the Setup and Teardown suite are passing in the run, but the actual test fails every time:
Failure Description on AWS Device Farm
My question is am I missing something from the configuration or is the script in need of any extra desired capabilities in order to actually execute the test on AWS Device Farm?
I changed the version of the tested app with another one, seems like the previous one, where the element could not be found was popping out an android system message, which could not be clicked with the provided code, hence the searched element could not be found.
Another thing that device farm is not so good at - providing real time observations on the running tests, which could save a lot of time in this situations.
Answering this for people who are still facing this issue.
You have to set up the automationName desired capability to the automation mechanism that you are using to automate the tests.
For me setting it up to uiautomator2 works.
capabilities.setCapability("automationName", "uiautomator2");
Two suggestions:
1. Set element waiting time to be less than 60 seconds, because default Appium session will timeout after that.
2. Create a screenshot for the failure, check whether the element was loaded correctly.
Hope this would help:)
Thanks,
Hongda
This has been making me work overtime and I still don't have much clues. I have a web application that is locally installed (pseudo-desktop app) that does the following:
Starts an SSH tunnel
directly runs ssh if on Mac OS X
uses PuTTy executable if on Windows
Opens Firefox or Chrome configured to use Socks5 proxy using the tunnel (localhost:port) via Selenium webdrivers.
For 1:
I have used both Runtime.getRuntime().exec(command); and Process proc = new ProcessBuilder(arguments).start();, and even gave Desktop dt = Desktop.getDesktop(); dt.open(f); a try. But nothing happens, no command prompt opens.
For 2:
I have tried using both Firefox:
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("network.proxy.type", 1);
profile.setPreference("network.proxy.socks", "localhost");
profile.setPreference("network.proxy.socks_port", 8088);
driver = new FirefoxDriver(profile);
And Chrome:
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability("chrome.switches", Arrays.asList("--proxy-server=socks5://localhost:8088"));
driver = new ChromeDriver(capabilities);
But similar to 1, no firefox or chrome windows open.
Note that this application works perfectly on Mac OS X Mavericks.
After several hours of debugging, I noticed that the processes are there. All the processes, from PuTTy, to Chrome, to Firefox. There were a lot of those already running in the background. The odd thing is that the user column of these processes is set to SYSTEM, while the normal browser sessions, for example, the user is set to "IT", which is my current Windows user account.
I have been trying to manually change the user in which these processes are invoked, but no luck so far.
So apparently, my application works in Windows as well, just not as I intended. All the processes, regardless if it's a command line script or a desktop application like firefox or chrome, they just don't appear but they run in the background under the user "SYSTEM". And I don't have any idea why. It sure doesn't look like it's supposed to be the default behavior. So if anyone have any idea, I'd really appreciate it.
Thanks.
Finally I was able to fix this! Thanks to this article (from a seemingly not related case):
Most Windows services -- including those run with the option "Allow
service to interact with desktop" in Windows XP and Vista -- do not
have access to many of the computer's resources, including the console
display. This may cause Automated GUI Tests to fail if you are
running Apache Tomcat as a Windows Service and are doing any GUI
testing. This is true at least for AWT and Abbot frameworks.
This limitation can be resolved by not running Tomcat as a Windows
Service, but instead through a "Scheduled Task" as an Application that
runs at logon. There are several options for doing this, an example
would be to run "$TOMCAT_HOME\bin\tomcat5.exe". When setting up the
scheduled task in Windows Vista consider choosing the check-box for
"Run with highest privileges" from the general tab, as this removes
the need to always provide administrator privileges and may resolve
other issues as well.
What I did was to NOT run tomcat7 as a Windows service, but instead just directly execute C:\Program Files\Apache Software Foundation\Tomcat 7.0\bin\Tomcat7.exe and everything worked perfectly. I can simply just put this as a scheduled task so it can still start automatically (or perhaps just put it on startup).
We have developed selenium webdriver script with junit+java using eclipse on window 7. All the scripts are working as expected now we are using this script for load testing using Jmeter. However, while running script system open multiple browser (200) based on user thread and it create system to hang, is there any way to handle this or we can run script without opening browser. I have come across xvfb tool, but not able to get java api for this tool to plugin in eclipse.
We have also tried using HtmlUnitDriver but as it does not support javascript hence the test is getting failed, also we tried HtmlUnit and found same thing.
Note: that we have writen webdriver script to maintain display item of element (autocomplete, image) on screen.
It would be great if anyone can help or provide more inputs on this...
Firstly, do not integrate selenium scripts with JMeter for load testing! It's not a good approach to follow due to the obvious consequences that you have mentioned in your post. I followed a similar apporach in the beginning when I was new to JMeter and selenium but suffered a great deal when it came to running load tests that spawned too many browser instances which killed the OS.
You can go for HtmlUnitDriver or any headless browser testing tools out there with JMeter, but still, they will be running the browser internally in the memory. Moreover if your application is heavily using Javascript, it won't help.
So I would suggest that you record a browsing session with JMeter Proxy and modify the script (set of requests) according to your needs and play those requests alone, with number of threads.
From a higher level, you should be doing this:
Add a JMeter test plan, listeners, thread group and setup JMeter proxy and record a browsing session where you enter something into the autocomplete textbox and you get certain results.
Stop your proxy and take a look at all the requests that come under your thread group.
As far as I know, when it comes to autocomplete plugins, multiple
requests are sent everytime you enter a letter into the textbox. For
example, for the word 'stackoverflow':
Request1: q=s Request2: q=st Request3: q=sta and so on
Here you can simulate this effect by including words such that all
words have the same length which in turn will let you have same
number of requests to be sent to the server.
So in your test plan, you will pass one word per Jmeter thread. You
can pass the words to a request, from a csv file by using jmeter
parametrization.
This will be a much memory efficient way of load testing instead of using selenium with JMeter. I had asked a similar question. You can check out the responses.
I am writing a protocol handler to launch a java application, calling a command like java -jar myApp '%1'. Currently I have implemented it for Chrome and it looks work correcly. Unfortunately I don't have the same behavior for Firefox and IE (weird uh?! X-D )
Here my implementation.
The protocol is named dgh.
During the first installation my application set the following keys in windows registry
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\dgh]
#="URL:DgHome Protocol"
"URL Procol"=""
[HKEY_CLASSES_ROOT\dgh\DefaultIcon]
#="C:/DGHOME/IPlusConf.exe,1"
[HKEY_CLASSES_ROOT\dgh\shell]
[HKEY_CLASSES_ROOT\dgh\shell\open]
[HKEY_CLASSES_ROOT\dgh\shell\open\command]
#="java -jar C:/DGHOME/Pch/lib/pch.teleconsulto.jar \"%1\""
On chrome this is enough.
On Firefox, I had to add some configurations in about:config.Following MDN on Firefox I set the following
network.protocol-handler.expose.dgh;true
network.protocol-handler.external.dgh;true
network.protocol-handler.warn-external.dgh;false
In this way firefox at least ask to me if I want launch an application and ask to me to select one: I don't want that, I would it call the command I set and advise the first time the user about that:
On IE nothing happens, it says can't open the web page reference by my link.
Here a set of link I used as test
Open call to kit1.teleconsulto
<a href="dgh://teleconsult/start?id='kit1.teleconsulto'">
Open teleconsult to kit1.teleconsulto</a>
Close call
Close client
On Phonendo
here some references:
Installing and Registering Protocol Handlers
http://msdn.microsoft.com/en-us/library/aa767916%28VS.85%29.aspx
I hope sincerely someone can help me
The problem you're having is that the you're calling the jar directly in your protocol handler. You need to invoke java.exe with the -jar parameter
Your registry key should look like this
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\digitalmgi]
#="URL:digitalmgi protocol"
"URL Protocol"=""
[HKEY_CLASSES_ROOT\digitalmgi\DefaultIcon]
#="C:\\myCoolIcon.ico"
[HKEY_CLASSES_ROOT\digitalmgi\Shell]
[HKEY_CLASSES_ROOT\digitalmgi\Shell\Open]
[HKEY_CLASSES_ROOT\digitalmgi\Shell\Open\Command]
#="\"C:\\Program Files\\Java\\jre7\\bin\\java.exe\" -jar \"C:\\MyPath\\myJar.jar\" \"%1\""
I understand that you have taken the approach of Registering in the system's registry but, If you are willing to take a different approach then, there is a Generic solution available at Generic-Protocol-Handler which surely will address the Cross Browser compatibility issue.
Please Mark this as Answer, if it helps :)
We have a CI environment with Jenkins running a test suite of Selenium Tests in a Windows (XP and/or Windows 7) VM. If I am not physically logged into the VM running these tests via RDP, all I see are black (blank) PNGs. I've tried all of the 'capture' methods available (both Base 64 encoded and file based) for multiple Selenium RC 2ish releases (e.g 2.0b2, 2.0rc3, 2.0.0, 2.1.0) and I get the same results for everything I've tried. Is anyone else running Selenium in a Windows CI deployment and able to capture screens? Or better stated, can anyone shed light on how I can capture screens in Windows, using the Selenium API without having to be physically on the box"?
If you are not logged onto the box, or you either closed or minimized the RDP connection, there is no desktop, and screen captures will be blank.
What you need to do is use a VNC server/viewer, so that the machine/vm in question has a visible desktop session.
We are also doing something very similar. We have a windows VM setup which is running Hudson and Selenium Grid.
When our test cases fail we capture a screenshot of the browser so we get more detail of why a test case failed.
We are using the #captureEntirePageScreenshotToString method
We're doing it, and it works for us. We're using JetBrains' TeamCity instead of Jenkins, running on Windows Server 2003. We run the Selenium RC server as a Windows service, using the Java Service Launcher.