Using Selenium webdriver on a custom webkit browser - selenium

I have successfully tested applications in FireFox using Selenium WebDriver, but one of our applications runs in a custom browser made using QTWebKit. Is it possible to use WebDriver to automate testing in a custom browser like this?

There is a webdriver for QtWebkit here: https://github.com/cisco-open-source/qtwebdriver
It also can automate qtwidget and QML aplications.
You should be able to use it to automate you custom browser, provided you preserved the QtWebkit APIs.

If QTWebKit has released a WebDriver executable for the browser, then yes.
Otherwise - no.

Related

What Is Selenium And What Is WebDriver?

What is Selenium?
When you open the official page of the Selenium, the first thing you read is "Selenium automates browser" in "What is Selenium?" section.
The section "Which part of Selenium is appropriate for me?" below offers the choice between Selenium WebDriver and Selenium IDE.
From this, I deduce that Selenium is a collection of tools and the collection comprises IDE, WebDriver API(language binding), Grid, Selenium Standalone Server, browser driver. One has to download the appropriate ones to build a project.
What is WebDriver?
WebDriver is an API. It is written in more than one language which and they are called language bindings. The API has functions to control a browser. You use the functions in writing a script that controls a browser in the way(test case) you want.
This is what I know. Please correct me wherever I'm wrong. I want to know the answers to the two questions in the interview point of view.
Selenium
Selenium is a free (open source) automated testing suite for web applications across different browsers and platforms. Primarily it is used for automating web applications for testing purposes, but is certainly not limited to just that. Selenium has the support of all of the major browser vendors who have taken (or are taking) steps to make Selenium a native part of their browser. It is also the core technology in countless other browser automation tools, APIs and frameworks.
Selenium is not just a single tool but a set of different software tools each with a different approach to support the test automation of an organization. From a broader perspective previously it had four components as follows:
Selenium Integrated Development Environment (IDE)
Selenium Remote Control (RC)
WebDriver
Selenium Grid
An year ago, Selenium RC and WebDriver are merged into a single framework to form Selenium 2.x. Perhaps, Selenium 1 refers to Selenium RC. The current released version is Selenium 3.x.
WebDriver
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. Selenium WebDriver fits in the same role as Selenium-RC did and has incorporated the original 1.x bindings and included the WebDriver API. It refers to both the language bindings and the implementations of the individual browser controlling code. This is commonly referred to as just WebDriver. In short, WebDriver is the remote control interface that enables introspection and control of user agents. WebDriver provides a platform and language-neutral wire protocol as a way for out-of-process programs to remotely instruct the behavior of web browsers.
Highlights of WebDriver
WebDriver is designed in a simpler and more concise programming interface along with addressing some limitations in the Selenium-RC API.
WebDriver is a compact Object Oriented API when compared to Selenium1.0
It drives the browser much more effectively and overcomes the limitations of Selenium 1.x which affected our functional test coverage, like the file upload or download, pop-ups and dialogs barrier
WebDriver overcomes the limitation of Selenium RC's Single Host origin policy.
Current Implementation
WebDriver is the name of the key interface against which tests should be written in Java/C#/Ruby/Python/NodeJS, the implementing classes which you can use are listed as below:
ChromeDriver
EventFiringWebDriver
FirefoxDriver
HtmlUnitDriver
InternetExplorerDriver
PhantomJSDriver
RemoteWebDriver
SafariDriver
What is Selenium
It is a suite of tools that can be used to automate web browsers testing.
Each tool serves different purpose.
List of tools:
Selenium IDE
Selenium RC
WebDriver
Selenium Grid
Selenium RC was merged with WebDriver since Selenium 2
What is WebDriver
Selenium WebDriver is an interface that permits us to execute tests over browsers.
Selenium WebDriver allows us to choose a programming language of your choice to create test scripts.
Please find the image below explaining how exactly WebDriver communicates with the browser :
What is Selenium?
Selenium is a framework where scripts are written to run and execute webDriver which in turn controls browser.
What is WebDriver?
WebDriver is an API, the name itself suggests driving the web browser or controlling the web browser by using libraries and commands.
The one and only job of WebDriver is to control the browser, it doesn't know anything about testing and how to interact with browser, At this point FrameWork comes into picture where Scripts are written to run and execute WebDriver.
What is Selenium?
You can say it is a web application automation framework.
What is WebDriver?
This is certainly an API but to understand easily you can think it as a library collection.
I think it's also worth noting that the WebDriver controls the browser, and that Selenium is the piece that sends/receives method calls and data from/to the driver using the "wire protocol" that the WebDriver creates. So the WebDriver is the bridge from the browser to any other code that wants to communicate with it. Selenium also provides an interface (in the coding sense...) that is standard across different WebDrivers. So when you declare a WebDriver type it is implementing the interface. (This is my current understanding anyway and I'm always learning something new!)

Can we use Sikuli with PhantomJS?

I want to use Sikuli with PhantomJS.Because web application which we are testing have so many http authenticate pop Ups. We are automating those pop ups by using Sikuli when we were using Selenium. But now we want to use PhantomJS because user is not able to do any other work while selenium web driver is performing testing on web application. Basically we don't want to block User for doing any other activity. So we are trying to use PhantomJS.
But as we know that PhantomJS is headless browser and Sikuli is image based testing tool . So can we use Sikuli With PhantomJS? If yes, then how can We use it? I know how to use Sikuli with PhantomJS Webdriver?
Thanks In Advance
No, you can't. As you stated PhantomJS is headless browser and Sikuli is image based testing tool, so there's no GUI to interact with.
Get some Virtual Machines and run tests on them, so no user is blocked.

Selenium Golang binding without server

There are many selenium webdriver binding package of Golang.
However, I don't want to control browser throught server.
How can I control browser with Golang and selenium without selenium server?
You can try github.com/fedesog/webdriver which says in its documentation:
This is a pure go library and doesn't require a running Selenium driver.
I would characterize the Selenium webdriver as a client rather than a server. Caveat: I have used the Selenium webdriver (Chrome version) from .Net and I am assuming it is similar for Go.
The way Selenium works is that you will launch an instance of it from within code, and it creates a live version of the selected browser (i.e. Chrome) and your program retains control over it. Then you write code to tell the browser to navigate to a page, inspect the response, and interact with the browser by filling out form data, clicking on buttons, etc. You can see what is happening on the browser as the code runs, so it is easy to troubleshoot when the interaction doesn't go as planned.
I have used Selenium to upload tens of thousands of records to a website that has no API and only a graphical user interface. Give it a chance.

HTMLUNIT with Headless Selenium

I am trying to scrape a website that contains images using a headless Selenium.
Initially, the website populates 50 images. If you scroll down more and more images are loaded.
Windows 7 x64
python 2.7
recent install of selenium
[1] Non-Headless
Navigating to the website with selenium as follows:
from selenium import webdriver
browser = webdriver.Firefox()
browser.get(url)
browser.execute_script('window.scrollBy(0, 10000)')
browser.page_source
This works (if anyone has a better suggestion please let me know).
I can continue to scrollBy() until I reach the end and then pull the source page.
[2] Headless with HTMLUNIT
from selenium import webdriver
driver = webdriver.Remote(desired_capabilities=webdriver.DesiredCapabilities.HTMLUNIT)
driver.get(url)
I cannot use scrollBy() in this headless environment.
Any suggestions on how to scrape this kind of page?
Thanks
One option is to study the JavaScript to see how it calculates what to load next. Then implement that logic in your scraping client instead. Once you have done that, you can use faster scraping tools like Perl's WWW::Mechanize.
You need to enable JavaScript explicitly when using the HtmlUnit Driver:
driver.setJavascriptEnabled(true);
According to [http://code.google.com/p/selenium/wiki/HtmlUnitDriver](the docs), it should emulate IE's JavaScript handling by default.
When I tried the same method, I got error messages that selenium crashed while connecting java to simulate javascript.
I wrote the script into execute_script method then the code works well.
I guess the communication between selenium and java server part is not configured properly.
Enabling the javascript with HTMLUNITDRIVERWITHJS is possible and quick ;)

What is the difference between Selenium's Remote Control vs WebDriver?

I'm not sure I quite understand the difference. WebDriver API also directly controls the browser of choice. When should you use selenium remote control (selenium RC) instead ?
Right now, my current situation is I am testing a web application by writing a suite with Selenium WebDriver API and letting it run on my computer. The tests are taking longer and longer to complete, so I have been searching for ways to run the tests on a Linux server.
If I use Selenium Remote Control, does this mean I have to rewrite everything I wrote with WebDriver API?
I am getting confused with Selenium Grid, Hudson, Selenium RC. I found a Selenium Grid plugin for Hudson, but not sure if this includes Selenium RC.
Am I taking the correct route? I envision the following architecture:
Hudson running on few Ubuntu dedicated servers.
Hudson running with Xvnc & Selenium Grid plugin. (Do I need to install Firefox separately ?)
Selenium grid running selenium RC test suites.
I think this is far more time efficient than running test on my current working desktop computer with WebDriver API.
WebDriver is now Selenium 2. The Selenium and WebDriver code bases are being merged. WebDriver gets over a number of issues that Selenium has and Selenium gets over a number of issues that Webdriver has.
If you have written your tests in Selenium one you don't have to rewrite them to work with Selenium 2. We, the core developers, have written it so that you create a browser instance and inject that into Selenium and your Selenium 1 tests will work in Selenium 2. I have put an example below for you.
// You may use any WebDriver implementation. Firefox is used here as an example
WebDriver driver = new FirefoxDriver();
// A "base url", used by selenium to resolve relative URLs
String baseUrl = "http://www.google.com";
// Create the Selenium implementation
Selenium selenium = new WebDriverBackedSelenium(driver, baseUrl);
// Perform actions with selenium
selenium.open("http://www.google.com");
selenium.type("name=q", "cheese");
selenium.click("name=btnG");
Selenium 2 unfortunately has not been put into Selenium 2 but it shouldn't be too long until it has been added since we are hoping to reach beta in the next couple of months.
As far as I understand, Webdriver implementation started little later than Selenium RC. From my point of view, WebDriver is more flexible solution, which fixed some annoying problems of SeleniumRC.
WebDriver provides standard interface for testing web GUI. There are several implementations of this interface (HTTP, browser-specific and based on Selenium). Since you already have some WebDriver tests, you must be familiar with basic docs like this
The tests are getting longer and longer to complete, so I have been searching for ways to run the tests on a linux server.
Did you try to find actual bottlenecks? I'm not sure, that elimination of WebDriver layer will help. I think, most time is spent on Selenium commands sending and HTTP requests to system-under-test.
If I use sleneium remote control, does
this mean I have to rewrite everything
I wrote with WebDriver API ?
Generally, yes. If you did not implement some additional layer between tests code and WebDriver.
As for Selenium Grid:
You may start several Selenium RC instances on several different [virtual] nodes, then register them in Selenium Grid. Your tests connect to Selenium Grid, and it redirects all commands to SeleniumRC instances, coordinating them in accordance with required browsers.
For details of hudson plugin you may find more info here