Reason behind adding HTML Unit Driver in Selenium 3.0.1 - java

As suggested in the below link, selenium has removed HTMLUnitDriver from selenium distribution as per its evolution strategy.
https://github.com/SeleniumHQ/selenium/issues/2381
While working on Selenium 3.0.1, i have found that HTMLUnitDriver is again distributed with Selenium server.
Can any one explain why again the HTML Unit driver is added as part of selenium server in Selenium 3. I have checked in Selenium 3.0.1 and Selenium 3.0.0.beta-2 . I did not check in the earlier betas of selenium 3.
The addition the browser driver in selenium distribution collides with the selenium evolution strategy that the browser driver need to be separated from selenium distribution. Can anyone tell me why this is added even if it is aganist the selenium evolution strategy?

Related

What is the difference between Selenium Webdriver and GeckoDriver?

I use Selenium every 5 years or so and everytime it has changed beyond recognition. I just started a new Selenium project, googled some quickstart guides such as https://www.toolsqa.com/selenium-webdriver/run-selenium-test/ (written in September 2020) and https://www.guru99.com/first-webdriver-script.html (© 2020) and both seem to use WebDriver, e.g., by initiating their examples with WebDriver driver = new FirefoxDriver(); although the latter has a disclaimer saying that from Firefox 35 (I have 82) and up you should use Geckodriver.
I use Selenium for Java 3.141.59 downloaded from https://www.selenium.dev/downloads/ but it only has two references to Geckodriver (at least that is all that is displayed when it enter Ge and autocomplete in my IDE), GeckoDriverInfo and GeckoDriverService (as a comparison, there are nine references to WebDriver).
I have read the information here https://github.com/mozilla/geckodriver but it didn't make me any wiser, nor did https://en.wikipedia.org/wiki/Selenium_(software)#Selenium_WebDriver (Geckodriver isn't even mentioned on this Wikipedia page).
What is the difference between Webdriver and Geckodriver?
Why, if one download the newest/current version of everything, isn't Geckodriver included if that is the recommended tool since several (?) years?
Why are guides that are written recently use Webdriver if Geckodriver is the way to go?
I think I have done a reasonably amount of research before asking this question but feel free to suggest improvements because I am genuinely confused.
WebDriver is a specification. It defines the way how UI interfaces can be automated. GeckoDriver is the implementation of such specification - it is the WebDriver implementation for Firefox browser.
So basically a WebDriver is a server that exposes REST API to one side and that knows how to control browser on another side.
Here is short explanation of E2E flow (for Firefox and Java):
You download Selenium java library. It provides Java client for interacting with web drivers
You download GeckoDriver
In your Java code you call WebDriver driver = new FirefoxDriver();
Selenium library starts GeckoDriver executable in OS native manner
In your Java code you call driver.get("http://my.url")
Selenium library forms REST call to the server that is started with GeckoDriver. It invokes the endpoint according to this section of specification.
GeckoDriver then translates this command to somewhat that Firefox understands so that the browser navigates to required page.
So basically you need 3 things to make everything work:
Selenium Java library that is basically a Java client for WebDriver REST API
GeckoDriver (that implements REST API according to WebDriver specification and translates it to commands which Firefox browse can understand)
Firefox browser
webdriver, is the parent of ChromeDriver ( from chrome ), GeckoDriver ( FireFox ), IEDriver and RemoteDriver. Possibly even more if they are supported. So, the GeckoDriver is used to control a FireFox Browser instance, but it implements the methods mentioned in the WebDriver interface.
GeckoDriver is not included as it is specific to FireFox only, other users may want to use other browsers.
To keep the flexibility of swapping out the implementations for different browsers. :)

Headless Chrome - getting blank page source

I'm trying to load a website with Chrome browser in headless mode using Selenium web driver. I face an issue with some specific websites. The page is loading, in the first 2-3 seconds it shows a page with "please enable javascript..." and after 3 seconds, page source goes blank.
I'm using Selenium and especially Chrome for long time and I am familiar with the platform. For the purpose of this case, I'm using Chrome Version 73.0.3683.86 , ChromeDriver 2.46.628411 (which is compatible according to Which ChromeDriver version is compatible with which Chrome Browser version?) on a Mac OS. selenium java version is latest - 3.141.59
I suspect that headless Chrome cannot handle specific content-type such as "svg" and any other GUI related HTTP response.
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments("--headless");
WebDriver driver = new ChromeDriver(chromeOptions);
driver.get("https://identity.tescobank.com/login");
Thread.sleep(3000);
System.out.println(driver.getPageSource());
driver.quit();
Expected result is to have the page source same as it is showing in non-headless mode.
Headless Chrome should be able to handle everything the normal Chrome can do:
It brings all modern web platform features provided by Chromium and the Blink rendering engine to the command line.
(see https://developers.google.com/web/updates/2017/04/headless-chrome)
Since only the login page of a bank causes you trouble, my guess is that the security of the page detects an anomaly and decides not to serve you.
One way they can do that is by looking at the User Agent string which contains HeadlessChrome.
That said, unless you're writing integration tests for the bank, your behavior is at least suspicious. If you have a valid and legal concern, clear it with the bank first. They might take actions against you, otherwise. Blocking your IP address (which could affect many people) or asking the police to have a word with you.
I was facing similar issue in my script, after login. Somehow refreshing the page resolved the issue.
driver.navigate().refresh();

Selenium WebDriver Safari (11.0) TypeError: Value is not a sequence

I'm trying to automate some regression tests for a site using Selenium but get the below console errors in Safari 11.0 whenever the WebDriver extension is active (not there when disabled):
TypeError: Value is not a sequence
TypeError: Not enough arguments
Looks like the same issue this user was seeing:
Value is not a sequence Safari exception
But in my case I need the extension in order to run my test build.
(Right? Or can I somehow disable it and still run automated tests?)
I use BrowserStack for my test browsers (I can see the TypeErrors by using their "Live" environment and opening the dev tools there) but need a way to test the site in "Automate" without the extension breaking the sections I'm trying to test.
When I execute my actual automated test I get the error "Expected condition failed: waiting for presence of element" because the needed section of the site entirely fails to load. The test works in other browsers and even older versions of Safari.
I'm new to Selenium and Java so any suggestions on how to get this test running in Safari 11.0 would be greatly appreciated.
My automated test uses Java (Java(TM) SE Runtime Environment (build 9.0.1+11), Selenium 3.7.1 and Eclipse.
Safari provides native support for the WebDriver API starting Safari 10. Source: https://webkit.org/blog/6900/webdriver-support-in-safari-10/. Safari 11 uses the same native Safari toolkit for supporting automation using Selenium and no longer needs the WebDriver extension. This option can be enabled for Safari 11 from Develop > Allow Remote Automation.
The errors you highlighted are due to the WebDriver extension and it should be removed/disabled when running Selenium tests on Safari 11. You should connect with their support team and check if they provide an additional capability to disable this.

Java Selenium WebDriver with Yandex

At the moment, I use Firefox as browser for my Java Application with Selenium. But Firefox is slow.
Is it possible to use Yandex as browser? Didn't find anything in Google. Does Selenium supports Yandex? For Chrome I need the .exe for using Chrome as browser. Is this possible with Yandex?
From what I recall, there is no WebDriver for the Yandex ("Яндекс") browser. In other words, there is no way to automate this browser through selenium.
Also, there are some performance tips and further links here:
Selenium WebDriver works but SLOW (Java)
Yandex browser can work with Selenium WebDriver using Operadriver.
System.setProperty("webdriver.opera.driver", "C:\\Users\\User\\IdeaProjects\\testselenium\\drivers\\operadriver.exe");
OperaOptions options = new OperaOptions();
options.setBinary("C:\\Users\\User\\AppData\\Local\\Yandex\\YandexBrowser\\Application\\browser.exe");
WebDriver driver = new OperaDriver(options);
driver.get("https://docs.seleniumhq.org");
This might be what you are looking for ( 4 years later :) ):
https://github.com/yandex/YandexDriver

Selenium Web driver and selenium RC

Is there a simple way i can convert my existing selenium RC scripts into the Webdriver format?
There's no way now to "convert" tests, but they can be tweaked to work with WebDriver using its Selenium Emulation.
You should keep in mind that not all Selenium methods are implemented in WebDriverBackedSelenium. However in future releases of WebDriver the support should expand and at some point (probably when Selenium 2 will reach the Beta status) the Selenium and WebDriver will be merged so the transition will be easier

Categories

Resources