I was setting up the environment for selenium in eclipse for automation testing. I have downloaded the Selenium Server 2.42.2 as well as Selenium Client & WebDriver Language Bindings for java from here
My Question,
In Many website, eclipse has been configured with selenium webdriver alone. But in some other sites like this suggested to install only selenium client driver bindings alone
Initially, i have configured using selenium server alone and run the basic tests in firefox browser and its works fine. Please advice us the need to set up the selenium client driver binding libs for selenium.
is java client driver bindings is a sub set of selenium webdriver? can i run automated test scripts without java client driver jar?
what are the usage of selenium server and java client driver and how both differs from each other? any example would be much helpful.
1.Is java client driver bindings is a sub set of selenium webdriver? can i run automated test scripts without java client driver jar?
If you want to write your selenium test cases using java, yes it is necessary to have.So you can say java client driver bindings is a subset of selenium webdriver to write and execute your test cases using java.
2.What are the usage of selenium server and java client driver and how both differs from each other?
Selenium Server.jar is used to run selenium server which was mandatory to run while there were Selenium RC only. Now with the arrival of Selenium 2.0 if your test cases are being executed on your local machine only you may not require Selenium Server.
If you want to run your test cases on a remote machine using RemoteWebdriver then only you would be needing Selenium Server.You can say its more or less the part of Selenium Grid.
Related
Anyone can explain how communication happen between browser and web-driver?. How does webdriver object read and identify html elements in browser ?. For that what is the relationship between webdriver object and browser and how to build the relationship browser and webdriver object?
driver = new FirefoxDriver();
driver.findElements(By.id("element"));
The communication between webdriver and browser happens through a json-wire protocol which is specified in the W3C documentation. All browsers that webdriver supports, uses this same protocol.
How does webdriver read and identify elements in a page? This varies from browser to browser.
Firefox - webdriver gets installed as a plugin in your browser while running the test. The webdriver server will send the json-commands to this plugin and those commands will get executed in the browser. The plugin is built within the webdriver jar file. It will get installed while running the test.
Chrome - For testing chrome, you would also need a chromedriver.exe file. This chromedriver.exe acts similar to the firefox plugin. It can receive the commands from webdriver server and execute it on the browser
IE - Similar to Chrome, IE executes with the help of InternetExplorerDriver.exe.
You can understand more about the functioning by looking at the different DriverFile source code in github.
You can also get an understanding about the working from here - http://www.aosabook.org/en/selenium.html.
I am not sure how updated this page is, but should help to understand the concept.
I work for a Music company and have my Automation/Regression suite built on Java, jUnit, Selenium WD, Ant framework.
I use Selenium Grid to run the tests on Various Grade A browsers.
Now we are moving to Continuous Integration (Jenkins) setup and I need to run tests on a Linux machine(CentOS) which does not have a UI.
I started off with the following setups to run regression
Run the above mentioned tests (Java, SeleniumWD, JUnit and Ant) in Linux box using Xll, xvfb and Firefox headless browser.
Run the tests on the Linux box using a PhantomJS browser setup.
IN BOTH THE CASES ALL THE TEST THAT REQUIRE FLASH CONTENT TO BE LOADED AND TESTED Fails.
I am NOT ABLE TO ACCESS THE WINDOWS/MAC Machine via/through LINUX BOX (using Hub/node Selenium grid options), connection timed out error is consistent.
IT WOULD BE REALLY HELPFUL IF THERE IS SUGGESTIONS/WORK AROUND/Frameworks TO HANDLE this situation.
Not having windows shouldn't be a problem. Can you setup XWindow sessions and run slave agent there to run real browser session?
Both Firefox and Chromium should work with CentOS.
I am trying to implement some Selenium 2 Webdriver tests with JUnit. The documentation on SeleniumHQ.org and the web is confusing to me because it seems to jump back and forth between Selenium RC and Webdriver. Plus, my Java is not very strong. I've took a few courses years ago, but haven't used it much. I want to have JUnit tests run from a headless CI server, and have Firefox run on a remote client system by using Webdriver.
From what I've gathered, I can use the following code to open a Webdriver-controlled instance of Firefox on my local system. The web site I'm testing has an untrusted SSL/TLS certificate, so I need to tell the Firefox driver to accept untrusted certificates. This works great locally:
FirefoxProfile profile = new FirefoxProfile();
profile.setAcceptUntrustedCertificates(true); // NOTE: this is the default behavior
RemoteWebDriver driver = new FirefoxDriver(profile);
Selenium selenium = new WebDriverBackedSelenium(driver, baseurl);
But I can't figure out how to do this on the remote system using Webdriver. The two approaches seem totally incompatible. The code above does not fit in any way into the following code that I have been using for using Webdriver remotely:
Selenium selenium = new DefaultSelenium(host, port, browser, baseurl);
selenium.start();
Now, I have spent many hours working with custom Firefox profiles on the remote test system. It worked in the summer of 2012, but after recent OS and browser updates, it stopped working. It seems much better to create the Firefox driver profile and call setAcceptUntrustedCertificates(true). Is it possible to use Webdriver to run tests in a browser on a remote system and also have the browser ignore untrusted SSL/TLS certificates?
As mentioned in your question, you don't need to set any property for accepting untrusted certificates explicitly. By default webdriver accepts untrusted certificates. Rather than using a webdriverbacked selenium, you should use the remotewebdriver directly like:
Webdriver wd = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), DesiredCapabilities.firefox());
Here http://localhost:4444/wd/hub is the URL of the Hub to which tests should be send for execution. When you start the tests, hub will look for remote nodes that have registered with firefox capability.
Personally I would suggest to read documentation at http://code.google.com/p/selenium/wiki/Grid2 rather than seleniumhq.org. As far as I know, selenium team is trying to get the seleniumhq documentation updated. You can also contribute to it :)
First of all i will recommend sticking to webdriver if you are using webdriver backed selenium just for profile. You can define profile to be used on your local machine as
File file = new File("firebug-1.8.1.xpi");
FirefoxProfile firefoxProfile = new FirefoxProfile();
firefoxProfile.addExtension(file);
firefoxProfile.setPreference("extensions.firebug.currentVersion", "1.8.1");
WebDriver driver = new FirefoxDriver(firefoxProfile);
To Answer Your Question: I will quote Simon Stewart's solution from here:
FirefoxProfile profile = new FirefoxProfile();
profile.setAcceptUntrustedCertificates(true);
DesiredCapabilities caps = DesiredCapabilities.firefox();
caps.setCapability(FirefoxDriver.PROFILE, profile);
Use this profile to create the remote driver.
Now if this doesn't work than may be we can write-up a bug (or at least a feature request).
post edit: I can not really test this solution as I dont have a cert issue site readily available. So in a way I would be looking towards you feedback to get the real picture... :)
When I asked this question, I didn't understand the distinction between Selenium objects and WebDriver objects. Even though I was specifically trying to learn about Selenium 2's "WebDriver" feature, I foolishly thought that I could write a "Selenium 2 Webdriver" project with Selenium 2 objects. That may sound obvious to someone who has experience with these tools, but that distinction was still not clear in my mind after reading "Selenium 2" books and project documentation.
As I result, I was writing Java code to instantiate a Selenium object to examine a web page, and trying to pass the Selenium object a WebDriver object, in the hope that the test would run on a remote server.
Now it seems clearer: The Selenium and WebDriver projects merged into a new umbrella project named (confusingly) Selenium 2.0, but they are distinct and separate tools within Selenium 2. If I want to use the WebDriver API, it seems that I must convert any existing Selenium objects to WebDriver objects. There appears to be no useful interaction between the two tools.
For example, in my project I had the following code. It ran great on my local desktop system's web browser:
Selenium selenium = new DefaultSelenium(host, port, browser, baseurl);
selenium.get(urlPath);
selenium.type(username_field, username);
selenium.type(password_field, password);
selenium.click(login_button);
But I want to be able to run that test on a headless continuous integration server, not my desktop system. I have converted the code to use a WebDriver object instead of a Selenium object. Now it runs on a remote system connected to a Selenium Grid 2 server:
WebDriver driver = new RemoteWebDriver(new URL("http://10.0.0.29:4444/wd/hub"), capability);
driver.get(urlPath);
driver.findElement(By.name(username_field)).sendKeys(username);
driver.findElement(By.name(password_field)).sendKeys(password);
driver.findElement(By.className(login_button)).submit();
I hope other people wanting to learn how to use WebDriver in Selenium 2 will not waste as much time as I did reading about Selenium objects, thinking that the Selenium object is part of WebDriver. My current [n00b] advice is to ignore anything that mentions Selenium objects, and focus purely on finding out as much as you can about WebDriver objects. A good place to start is the WebDriver documentation at SeleniumHQ.org:
http://seleniumhq.org/docs/03_webdriver.jsp#webdriver-and-the-selenium-server
As A.J. suggested in his answer, also take a look at the Selenium Grid documentation:
http://code.google.com/p/selenium/wiki/Grid2
And PS: a remote Selenium 2 Webdriver instance accepts untrusted SSL/TLS certificates automatically, by default. No code required.
$pip install selenium
$sudo apt-get install firefox xvfb
from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.keys import Keys
browser = webdriver.Firefox()
browser.get("http://www.yahoo.com")
This is what I have so far, for Selenium. It seems to work, except it says, "Error: no display specified"
My question is: Do I need to run the selenium jar? It doesn't seem to matter whether I run it or not...
First let me define for you client mode and server mode:
Client mode: where the language
bindings connect to the remote
instance. This is the way that the
FirefoxDriver and the RemoteWebDriver
client normally work.
Server mode:
where the language bindings are
responsible for setting up the
server, which the driver running in
the browser can connect to. The
ChromeDriver works in this way
In the current trunk all of the browsers can run in client mode although you must specify the ChromeDriver.exe path. Server mode can be used to do the same thing. You can set up the jar to run to act as a server for a particular browser. You then connect to that server. If you do this you'll see a Jetty server being set up and it handling requests. If this is not happening then you are not using server mode. As I can see from your code you are currently using client mode so there is no need to run the jar unless you want the extra remote functionality of it.
Running the jar is useful if you want to run tests on a remote machine in which case you run the jar there then connect to it from your local machine. The jar will then deal with launching browsers on the machine it is running on and forwarding actions to it.
I believe in the past with the Selenium RC API, it was necessary to always run the jar but with WebDriver this is not the case.
No, you don't need to run Selenium RC server. You can also use the Webdriver method instead, the preferred method for functional testing, which is a "direct" control of the browser as far as I can tell.
I think the server method "Selenium RC server" is more useful for load testing or multiple user testing, especially in the context of using it with Selenium Grid .
I am trying to use Selenium 2.0 (Webdriver) to implement a series of tests. Before these tests can run, I have to login into the application. Since the application is not my 'own' (testing api-built functionality), each test should not be logging into my application to run.
I would prefer to do the following:
Connect my webdriver tests to my open Firefox browser (already loggedin)
Run my webdriver projects with the same browser.
I understand that Selenium usually assigns a session id to its browsers. However, the current Java implementation of Selenium 2.0 driver does not make use of session id (maybe it does but I don't know where to find it. )
Can someone provide some direction on how to resolve my issue (existing browser and run multiple tests with Selenium 2.0 (java))? Any code provided would also be helpful. Thanks!
Here is what I have learnt:
Selenium 1: As Ioan suggested earlier, use "-firefoxProfileTemplate" when starting up the Selenium RC server and point to the location of your Firefox profile.
Selenium 2: I suppose you can use the Selenium 1 RC server, however, since Selenium 2 uses WebDriver, you can point to the profile information within your code.
File profileDir = new File("/Users/_____/selenium/FFprofile");
FirefoxProfile profile =
new FirefoxProfile(profileDir);
WebDriver driver = new FirefoxDriver(
profile);
Notes:
Make sure you run "firefox -profilemanager" to create your initial profile and save your login information.
Allow the browser/website to always store your authentication credentials avoiding "popup"/"login" wwindows, etcs.
Hope this helps somebody who may run into a similar issue: Using the same browser profile in Selenium, etc.