How to use OperaChromiumDriver for opera version >12.X - selenium-webdriver

I understand that to work on opera versions > 12.X, Operachromiumdriver has been developed. At the same time I couldn't get this to work. I downloaded the windows version of operachromiumdriver.exe from https://github.com/operasoftware/operachromiumdriver/releases but to no avail. Can someone help me with this . Please tell me if my understanding is right.
Thanks

I have found the solution running opera 25+ using OperaChromiumDriver.exe.
Install Opera 25+ (I installed Opera 25)
Download OperaChromiumDriver https://github.com/operasoftware/operachromiumdriver/releases
Extract the zip file to a location on the computer
Use the following code to open Opera
System.setProperty("webdriver.chrome.driver", "C:/Users/user/Downloads/operadriver-0.1.0-win32/operadriver-0.1.0-win32.exe");
WebDriver driver = new ChromeDriver();
driver.get("https://www.google.com");
driver.findElement(By.name("q")).sendKeys("Selenium");
I have used new ChromeDriver(). This will start Opera since we are using OperaChromiumDriver. I think this is because the new Opera is based on Chromium and OperaChromiumDriver is a WebDriver implementation derived from ChromeDriver [See https://github.com/operasoftware/operachromiumdriver].
Hope this helps you.

OperaChromiumDriver now works with Opera 26+ but only with a remote instance so far... Download and launch the appropriate binary from
OperaChromiumDriver Binary Releases
They have examples for Desktop versions in python but here's what worked for me in Java. Many ChromeOptions do not work though it says they should... you will have to test to know for sure but the setBinary does work.
DesiredCapabilities capabilities = DesiredCapabilities.opera();
ChromeOptions options = new ChromeOptions();
options.setBinary("/path/to/opera");
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
driver = new RemoteWebDriver(new URL("http://127.0.0.1:9515"),capabilities);

Operachromiumdriver
Download selenium Drivers. As their is no direct opera driver, OperaChromiumDriver is based on ChromeDriver, so we are Using ChromeOptions to set binary location of operadriver.exe
Chromium-based versions of Opera starting from version 26.
String operaChromiumDriver = "E:\\Drivers\\operadriver.exe";
String operaBrowserLocation = "C:\\......\\opera.exe"
System.setProperty("webdriver.opera.driver", operaChromiumDriver);
ChromeOptions options = new ChromeOptions();
options.setBinary(operaBrowserLocation);
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
OperaDriver browser = new OperaDriver(capabilities);
WebDriver driver =browser;
driver.get("https://in.yahoo.com/");
thanks to Lukus Answer(1) to complete my work.

Related

Can't open Private window in Edge Browser using Selenium

I have tried below mentioned code, but its not working in my framework.
Selenium -3.141.59
Microsoft Edge- 81.0.416.72
EdgeOptions options = new EdgeOptions();
options.setCapability("inPrivate", true);
WebDriver driver = new EdgeDriver(options);
You could try to add argument inprivate to make Edge Chromium open in Private mode using Selenium WebDriver.
Please refer to the following steps:
Download the language binding of Selenium 4.00-alpha05 from here.
Download the matching version of Microsoft Edge Driver from this page.
Then, using the following code (it works well in C# and Java application):
EdgeOptions edgeOptions = new EdgeOptions();
edgeOptions.addArguments("-inprivate");
WebDriver driver = new EdgeDriver(edgeOptions);

Remote WebDriver UnreachableBrowserException: Could not start a new session

I got this exception for all browsers. For example, I create a remote webdriver on chrome like this:
caps = DesiredCapabilities.chrome();
ChromeOptions options = new ChromeOptions();
options.addArguments("disable-infobars");
caps.setCapability(ChromeOptions.CAPABILITY, options);
webDriver = new RemoteWebDriver(new URL("http://myIP:5555/wd/hub"), caps);
And I got UnreachableBrowserException as follow:
org.openqa.selenium.remote.DesiredCapabilities chrome
INFO: Using `new ChromeOptions()` is preferred to `DesiredCapabilities.chrome()`
org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
But I check my selenium hub at http://myIP:4444/grid/console, everything is fine, the node is stil registered. I then check my node at http://myIP:5555/wd/hub/static/resource/hub.html, I still can click "Create Session" to create a session for all browsers.
I just got this exception today, it still worked few days ago. I am using Selenium 3.11.0, IntelliJ 2017.3, all drivers and browsers are latest versions.
I googled here, but I can't find a solution for this while my gird is still running. Any help much appreciated.
The error says it all :
INFO: Using `new ChromeOptions()` is preferred to `DesiredCapabilities.chrome()`
The current implementation of Selenium while invoking RemoteWebDriver supports the ChromeOptions and you can use the following code block :
ChromeOptions options = new ChromeOptions();
options.addArguments("disable-infobars");
webDriver = new RemoteWebDriver(new URL("http://myIP:5555/wd/hub"), options);
Update
As per your comment update the documentation at seleniumhq-documentation is yet to be updated. Here are the relevant bytes from the Selenium Release Notes :
Selenium v3.5.0 :
* Start making *Option classes instances of Capabilities. This allows
the user to do:
`WebDriver driver = new RemoteWebDriver(new InternetExplorerOptions());`
Selenium v3.6.0 :
* All `*Option` classes now extend `MutableCapbilities`
`new RemoteWebDriver(new ChromeOptions());`
Selenium v3.7.0 :
* Migrated from using `DesiredCapabilities` to either
`MutableCapabilities` or (preferably) `ImmutableCapabilities`.

Selenium Secure Socket Layer Issue in Selenium 3

How could I handle ssl certifiaction error in selenium 3 and above for firefox 49+.
It will be helpful if anyone could answer. Thanks in advance
For chrome :
DesiredCapabilities SSLErr = DesiredCapabilities.chrome ()
SSLErr.setCapability (CapabilityType.ACCEPT_SSL_CERTS, true)
WebDriver driver = new ChromeDriver (lSSLErr);
or
ChromeOptions option= new ChromeOptions();
option.addArguments("headless");
option.addArguments("ignore-certificate-errors");
WebDriver d=new ChromeDriver(option);
For Firefox
FirefoxProfile profileSSL = new FirefoxProfile();
profileSSL.setAcceptUntrustedCertificates(true);
profileSSL.setAssumeUntrustedCertificateIssuer(false);
driver = new FirefoxDriver(profileSSL)
Hi Actually none of the above worked for me, I am using Selenium 2.35.1 and Firefox 49. So I used try catch method, where I am catching that WebDriverException and clicking on exception using selenium and AutoIT to close the window based popup

Which version of firefox is compatible with Selenium 3.3.1 without use of gecodriver

I want to run scripts on Firefox having selenium webdriver version installed as 3.3.1 but w/o any use of geco driver.
kindly help as I am working on client machine
No, you cannot work with Selenium 3.3.1 without using geckodriver.
Selenium 2.53 was the last version which worked without gecko driver with Mozila Firefox (till version 47.x)
To work with Selenium 3.3.1 you need to mandatory download gecko driver v0.15.0 from here and save it. Upgrade your Mozila Firefox to 53.x
Note that: For gecko driver v0.15.0 you must upgrade to Selenium 3.3 since this release aligns HTTP responses with the WebDriver standard.
Next you need to provide the absolute path of the gecko driver in your code. Your code will look like:
System.setProperty("webdriver.gecko.driver", "C:\\Utility\\BrowserDrivers\\geckodriver.exe");
FirefoxDriver driver = new FirefoxDriver();
driver.manage().window().maximize();
driver.get("https://www.facebook.com/");
driver.findElement(By.name("email")).sendKeys("your_username");
Let me know if this answers your question.

Not able to automate Opera browser through Selenium WebDriver

I'm automating a web application which runs in 3 browsers, IE, Mozilla and Chrome.
Now when I try to run the same code in Opera with different capabilities, it opens Opera browser but in URL only data; is displayed and my tests are not running.
Here is my sample code:
DesiredCapabilities capabilities = DesiredCapabilities.operaBlink();
System.setProperty("webdriver.opera.driver", "C:\\Important\\Test\\web\\src\\test\\resources\\operadriver.exe");
driver = new OperaDriver(capabilities);
driver.manage().window().maximize();
I'm getting following error:
org.openqa.selenium.WebDriverException: Opera not reachable (Driver info: OperaDriver=0.2.0 (ba47709ed9e35ce26dbd960fb5d75be104290d96),platform=Windows NT 6.1 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)
I tried this with Windows 10, Selenium 3.5.2, Opera 52.0 and OperaDriver 2.35 and the following code works for me.
DesiredCapabilities capablities=DesiredCapabilities.opera();
System.setProperty("webdriver.opera.driver", "C:\\automation\\opera\\operadriver.exe");
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.setBinary("C:\\Program Files\\Opera\\launcher.exe");
capablities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);
OperaDriver driver = new OperaDriver(capablities);
driver.get("https://www.google.com");
driver.findElement(By.name("q")).sendKeys("how to use opera with selenium");
Please Try with
DesiredCapabilities capabilities = DesiredCapabilities.opera();

Resources