I'm new in using Selenium.
Selenium IDE is a user-friendly firefox plugin. I have no problem in using it. However, I found that the documentation for other Selenium tools such as Selenium RC and Selenium Core is quite confusing for beginners. It seems that the author assume that the readers already have deep knowledge in using these tools.
For example, when I try to figure out how to setup Selenium RC to test a webserver, the only diagram i can find from the Selenium website is this:
http://www.sparksupport.com/blog/wp-content/uploads/2010/11/selenium-rc.png
From this diagram, i can't even see which one is the webserver under test and where should i install the Selenium components.
At first I thought this diagram is a bit weird and i should be able to get a better diagram from other websites. I was surprised to find that almost all Selenium RC setup diagram on the internet are similar to this diagram (clones). No one has ever attempted to create a different diagram or give more description for Selenium RC setup.
Appreciate if anyone can give me guidance on how to setup Selenium RC. The things that i want to know are:
Can i use Selenium RC to test any website on the Internet?
How to setup Selenium RC?
Is my current setup correct? My current setup is like this: In a LAN network which has access to the Internet, I have 3 servers. Server-1 comes with IE8, Server-2 comes with Firefox 3.6. Server-3 will be used as the Selenium RC server. So, Selenium RC in server-3 will remotely control server-1 and server-2 to start up IE and FF. Server-1 and 2 will use server-3 as the HTTP proxy to connect to any webserver on the Internet. If I want to test a website such as yahoo.com, I can write Selenium script and let it run in Server-3 to control the IE and FF in server-1 and 2.
This info is related to Selenium 1.
Selenium system consists of 3 parts:
selenium core - that is javascript library that will be used to simulate user actions
selenium RC - this is selenium-server.jar - mediation JETTY server that will receive requests from selenium client. Selenium Server RC (Remote Control) should be on the same machine where the Browser placed
Selenium client - java/ruby/... library that you will be use with your tests to communicate with Selenium RC.
It will be helpful if you provide language that you use for your tests and other technical details.
About your questions:
can
type in command line -> java selenium-server.jar
or you can use class SeleniumServer in your program
please use text formatting when ask questions.
server-1 will has IE8 and SeleiumServer
server-2 will has FF and yet one SeleniumServer
server-3 will has you client tests
FYI - you can run all together on one PC
The below diagram is of a web application test system that I've implemented on numerous occassions. This does not show you specifically details on installing Selenium RC, but it does show you, at a high level, all of the necessary system components and how they interface.
We hope you can use it to get ideas on how to implement your own systems using open source solutions like Selenium, MySQL and Perl.
Our team understands that not all web sites are created equal, and, in order for any automation initiative to be successful a thorough analysis must be performed of not only the web application, but the business as well. Since our client's QA team, while technically savvy, were not programmers we decided to implement a page object design pattern where all of the "magical selenium commands" were abstracted in a class and exposed to the test developers as methods they would call from their test scripts.
The resulting implementation, as seen in the diagram below, is currently deployed and keeping management and interested parties up to date on the status of key functional areas of the web site.
System Diagram - Click to View
In the coming weeks, we are going to be covering each implementation step in more detail. We look forward to any feedback!
Web and Mobile Automation Blog
Related
I try to find a service which provides a functionality that allow me to create manual tests autmation for web-based applications in simple way with visual constructor without any coding, so it could be
simple in use without any coding on selenium or another framework tool
has option to set testing in schedule mode via the web interface to perform regression testing
has ID's validation and shows possible inconsistencies
The main point is reproduce manual tester's work without using automation scripts and do it in simple way in order to a beginner will be able to work with it.
So could anyone describe his own experience ?
There are two main options I would consider
to find a service which provides a functionality that allow me to create manual tests autmation for web-based applications in simple way
First one is BrowserStack and you can record your Selenium tests using the Selenium IDE extension for FireFox. It can export the recorded steps into your favorite language (C#, Python, ect). You can execute these recorded scripts on BrowserStack by pointing the hub URL to Browserstack's Selenium hub ‘http://hub.browserstack.com/wd/hub’ along with your username and Automate key. Your 'username' and 'automate key' can be found at Account --> Automate1, after you have logged in to your account.
I would suggest, you refer to the comprehensive documentation on BrowserStack Automate. It takes you step-by-step through the product and all its features. You can select the language you are using and get started with BrowserStack Automate. If you have any more questions, feel free to email at support#browserstack.com. They will be happy to help you out.
Second option is SauceLabs and the Selenium Builder. This is the docs that will guide you. Further more you have CI integrations for Jenkins and Bamboo.
You can use Selenium IDE to create your automated tests. With this Firefox plugin, you can record a test in your browser.
Once you're done recording, you can export the test and upload it to TestingBot. There you can specify the browsers you want to run the test on. TestingBot will then run your test across all the browsers you specified.
I am using htmlunit for web scraping - logging to a website on behalf of the users, settings something in their profile and then come back.
Just using pure Htmlunit and no selenium framework.
Now my question:
WebClient webClient = new WebClient(BrowserVersion.INTERNET_EXPLORER_11);
Does this statement - creates a browser instance on the machine where i am executing the code or what it does?
I am using BrowserVersion.INTERNET_EXPLORER_11 as this is an accepted browser at that website.
How Selenium is different than htmlunit - i know we can use htmlunit as a webdriver in Selenium. Does Selenium needs a native browser instance on the machine where the code is getting executed? Does Selenium creates browser instances?
My use case is - I will be having multiple users accessing this application. I know WebClient in htmlunit is not thread safe(so have to code it as Spring proto type bean).
Is there any suggestions regarding this?
Any help is greatly appreciated.
HTMLUnit is a headless browser. So no window will be created if used with Selenium either. Setting the BrowserVersion will just tell HTMLUnit to present itself to the server as if it were a given browser (AFAIK, it will just change the User-Agent but might perform additional internal processing depending on the version). I guess this answers most of the questions but the last one.
Regarding asking for suggestions on how to implement this I would try to avoid logging in to a website that way. If the website does not provide an API for this then it is likely that it is agains the Terms Of Service. Assuming it is not, you will have to create new WebClient instances for each user each time the data needs to be extracted from the other site.
We have are planning to design a system where we are planning to invoke the Selenium test that is present in a remote machine with url for testing. The selenium program should open 3 browsers for example IE, FF and Chrome and open the page and take a screenshot of it. Later These screenshots should be sent from this machine to the java application.
Is it possible to achieve this functionality ? If so could you please guide me on how to do this ?
Yes, you need to start a Selenium Grid/Node server on the remote machine that is configured to run all 3 browser types. That configuration isn't easy but it involves launching the grid from a .json config file. Then, your local program needs to just run the 3 tests either in 3 simultaneous threads, or one at a time using typical Selenium code.
Each test needs to define a Selenium Augmenter to get screenshots. There are lots of examples on Google.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 3 years ago.
Improve this question
I am trying to understand testing framework better and been looking into Selenium. I've used HTMLUnit before, mainly when I needed to scrape some information off website or the likes.
In the context of writing test automation, what's the advantage / disadvantages of Selenium vs HTMLUnit? Looks to me Selenium is more complicated to set up than HTMLUnit, although at the same time there's a HTMLUnitDriver for Selenium which I think behave the exact same way as in HTMLUnit itself?
Selenium obviously provides more robust framework, it has the Selenium RC for pararel testing, it also has different browser drivers that can be used - although when you used the browser drivers, the test will actually open/close a browser application rather than headless.
May be I am not understanding Selenium correctly. Some directions and pointers would be great!
On another note - a separate question - I am also looking at doing automated testing on mobile browser, I see that Selenium has an IPhoneDriver for it, but then this is not a headless testing either as it requires actual iOS simulator.
Is there anyway to do headless testing on mobile sites? Would changing user-agent be sufficient? I've seen a couple posts around changing user-agent that seem to have their own challenges, eg. Set user-agent in Selenium RC
Thanks a lot!
well, would try to explain differences in detail.
Speaking about parallel testing, it better to use selenium grid.
Basic concept of selenium RC and selenium grid.
You can get into more details here
Some words about selenium webDriver:
The primary new feature in Selenium 2.0 is the integration of the WebDriver API. WebDriver is designed to providing an simpler, more concise programming interface along with addressing some limitations in the Selenium-RC API. Selenium-WebDriver was developed to better support dynamic web pages where elements of a page may change without the page itself being reloaded. WebDriver’s goal is to supply a well-designed object-oriented API that provides improved support for modern advanced web-app testing problems.
How Does WebDriver ‘Drive’ the Browser Compared to Selenium-RC?
Selenium-WebDriver makes direct calls to the browser using each browser’s native support for automation. How these direct calls are made, and the features they support depends on the browser you are using. Information on each ‘browser driver’ is provided later in this chapter.
For those familiar with Selenium-RC, this is quite different from what you are used to. Selenium-RC worked the same way for each supported browser. It ‘injected’ javascript functions into the browser when the browser was loaded and then used its javascript to drive the AUT within the browser. WebDriver does not use this technique. Again, it drives the browser directly using the browser’s built in support for automation.
WebDriver and the Selenium-Server
You may, or may not, need the Selenium Server, depending on how you intend to use Selenium-WebDriver. If you will be only using the WebDriver API you do not need the Selenium-Server. If your browser and tests will all run on the same machine, and your tests only use the WebDriver API, then you do not need to run the Selenium-Server; WebDriver will run the browser directly.
There are some reasons though to use the Selenium-Server with Selenium-WebDriver.
You are using Selenium-Grid to distribute your tests over multiple
machines or virtual machines (VMs).
You want to connect to a remote machine that has a particular browser
version that is not on your current machine.
You are not using the Java bindings (i.e. Python, C#, or Ruby) and
would like to use HtmlUnit Driver
Selenium-WebDriver’s Drivers
WebDriver is the name of the key interface against which tests should be written, but there are several implementations. These include:
HtmlUnit Driver
This is currently the fastest and most lightweight implementation of WebDriver. As the name suggests, this is based on HtmlUnit. HtmlUnit is a java based implementation of a WebBrowser without a GUI. For any language binding (other than java) the Selenium Server is required to use this driver.
Pros
Fastest implementation of WebDriver
A pure Java solution and so it is platform independent.
Supports JavaScript
Cons
Emulates other browsers’ JavaScript behaviour (see below)
JavaScript in the HtmlUnit Driver
None of the popular browsers uses the JavaScript engine used by HtmlUnit (Rhino). If you test JavaScript using HtmlUnit the results may differ significantly from those browsers.
When we say “JavaScript” we actually mean “JavaScript and the DOM”. Although the DOM is defined by the W3C each browser has its own quirks and differences in their implementation of the DOM and in how JavaScript interacts with it. HtmlUnit has an impressively complete implementation of the DOM and has good support for using JavaScript, but it is no different from any other browser: it has its own quirks and differences from both the W3C standard and the DOM implementations of the major browsers, despite its ability to mimic other browsers.
With WebDriver, we had to make a choice; do we enable HtmlUnit’s JavaScript capabilities and run the risk of teams running into problems that only manifest themselves there, or do we leave JavaScript disabled, knowing that there are more and more sites that rely on JavaScript? We took the conservative approach, and by default have disabled support when we use HtmlUnit. With each release of both WebDriver and HtmlUnit, we reassess this decision: we hope to enable JavaScript by default on the HtmlUnit at some point.
To investigate deeper into webDriver's setUp see this
From HtmlUnit documentation:
HtmlUnit is not a generic unit testing framework. It is specifically a way to simulate a browser for testing purposes and is intended to be used within another testing framework such as JUnit or TestNG.
So to conclude Selenium and HtmlUnit difference:
HtmlUnit is a java based implementation of a WebBrowser without a GUI and a way to simulate a browser for testing purposes and Selenium-WebDriver makes direct calls to the browser using each browser’s native support for automation. we can see that HtmlUnit provides API without GUI possibility for automation whereas WebDriver provides internal browsers' possibilities for automation.
Speaking about mobile automation,
Selenium also has an iPhone Driver
iPhone Driver wiki article
and Android Driver
Android Driver wiki article
See also this presentation
Unfortunately I can not give you my working experience evaluation of mobile drivers as I deal with web automation (no mobile). Also know that Cucumber (automation tool) is popular among mobile automators.
see this and this.
Hope it come a lil bit more clear for you now =)
Selenium and HTMLUnit are somewhat similar in concept, but Selenium is more mature/robust and has a lot more features.
Note that Selenium encompasses the recording (IDE) plugin for Firefox, which allows you to record tests and the RC/WebDriver automation framework which essentially drives a browser. The two can be used together to make test creation very easy.
The only advantage I could see to using HTMLUnit is that it is less resource intensive, so you could potentially run tests on less hardware, but with Selenium's parallel support even that isn't really true anymore.
When running tests from Jenkins overnight, you typically have no access to a windowing system such as X11 or Windows in which to run the web browser. I therefore see a benefit of using the HTMLUnit web driver in that case since it doesn't require access to a windowing system.
In my experience, HtmlUnit does a fine job with browsing automation, but might get a bit buggy when dealing with Javascript. I actually came to a case in which I wasn't able to automate an image download with HtmlUnit, and had to turn to Selenium, which performed beyond my expectations. The case is actually registered in an SO thread.
I have used Selenium WebDriver for automation.
There is a very easy method to causing the browser to be headless.
Simply apply ChromeOptions (In my case, other DriverOptions are available)
ChromeOptions("Headless")
There are many proficient methods that can come from using Options or Services, as another example
This will stop the Driver/CommandPrompt window from 'appearing' so it will remain 'silent' and unexposed.
ChromeDriverServices ("Silent")
At least at UX systems you can use for example Xvfb and point the browsers to that display to make them "headless"
See also http://infiniteundo.com/post/54014422873/headless-selenium-testing-with-firefox-and-xvfb
or How do I run Selenium in Xvfb?
I can see that since selenium 2.0, WebDriver and Selenium RC are packaged together for download. Now I primarily use WebDriver, but can I bring in Selenium RC in my testing scripts from now and then? Is there anything that Selenium RC is capable of but WebDriver is not, or vice versa?
You should probably start your research here (though you may have already gone over this): http://seleniumhq.org/docs/03_webdriver.html
I'll assume you're contrasting Selenium-RC to WebDriver, Selenium-IDE really isn't in the same ballpark.
Selenium uses JavaScript to automate web pages. This lets it interact very tightly with web content, and was one of the first automation tools to support Ajax and other heavily dynamic pages. However, this also means Selenium runs inside the JavaScript sandbox. This means you need to run the Selenium-RC server to get around the same-origin policy, which can sometimes cause issues with browser setup.
WebDriver on the other hand uses native automation from each language. While this means it takes longer to support new browsers/languages, it does offer a much closer 'feel' to the browser. If you're happy with WebDriver, stick with it, it's the future. There are limitations and bugs right now, but if they're not stopping you, go for it.
Selenium Benefits over WebDriver
Supports many browsers and many languages, WebDriver needs native implementations for each new language/browser combo.
Very mature and complete API
Currently (Sept 2010) supports JavaScript alerts and confirms better
Benefits of WebDriver Compared to Selenium
Native automation faster and a little less prone to error and browser configuration
Does not require Selenium-RC Server to be running
Access to headless HTMLUnit can allow tests to run very fast
Great API
I see this is an old question but found this is on the Selenium HQ home page:
Selenium WebDriver is the successor of Selenium Remote Control which
has been officially deprecated. The Selenium Server (used by both
WebDriver and Remote Control) now also includes built-in grid
capabilities.
So it's settled :-)
The biggest difference is RC runs from a vs, 2.0 uses Webdriver and launches the browser, instead of using a vs. In order to you RC in 2.0, check here: http://seleniumhq.org/docs/09_webdriver.html#emulating-selenium-rc
I dont know how to take 2.0 into RC though, but were do you see they are packaged together? They are two different products. Selenium 2 is webdriver, and Selenium RC is Selenium 1.
Personally, I found 2.0 a lot easier to program with. Plus by the end of the year Javascript alert support should be implemented, which is a huge plus!