How To run Opera version 38 through Webdriver (Selenium 2.53.1)? - selenium-webdriver

I am using Opera version 38 and learning automation , I am unable to automate my code with my Opera browser.
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", "C:\\chromedriver_win32\\chromedriver.exe");
WebDriver d = new ChromeDriver();
d.navigate().to("https://gmail.com");
}
This is the code for running in chrome but for opera am unable to get a driver (.exe file) from http://www.seleniumhq.org/download/ .

Related

Chrome version in invoking chromedriver

I have to download the same version of chrome to invoke chromedriver and my chrome version is 108.0.5359.124 and there is no version like this to download so i downloaded is 108.0.5359.71 so it gave me error
package Hala;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class Sellintroduction {
public static void main(String[] args) {
//Invoking the browser
System.setProperty("webdriver.chrome.driver" , "/Users/ahmedelgendy/Downloads/chromedriver");
WebDriver driver = new ChromeDriver();
}
}
Error occurred during initialization of boot layer
java.lang.module.FindException: Module processed.jcommander not found, required by org.seleniumhq.selenium.remote_driver

Get error org.openqa.selenium.firefox.NotConnectedException when running the selenium code

getting the below error
org.openqa.selenium.firefox.NotConnectedException
Firefox : 32.0
Eclipse : Version: Neon.1a Release (4.6.1)
Upgrade your firefox You need to install geckodriver from this link:
Gecko driver download from here
and then set the setProperty()
System.setProperty("webdriver.gecko.driver", "E:\\software and tools\\geckodriver.exe");
WebDriver driver = new FirefoxDriver();
driver.get("http://www.google.com");
If you are using selenium jar 2.53 and browser firefox 45.0, then no need to set gecko driver:
WebDriver driver = new FirefoxDriver();
driver.get("http://www.google.com");

Test case not running iin selenium webdriver

I tried to use the following code to open a URL in my local system. But I get error message as shown in screen shot.
Code
package First_test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class first_case {
public static void main(String[] args) {
// TODO Auto-generated method stub
// Create a new instance of the Firefox driver
WebDriver driver = new FirefoxDriver();
//Launch the Website
driver.get("http://127.0.0.1:3000");
// Print a Log In message to the screen
System.out.println("Successfully opened the website ");
// Close the driver
driver.quit();
}
}
error message
What shall I do to solve this problem? Thanx!
You need to install gecko driver. A brief introduction about it and how to install gecko driver can be found in following link. Hope this helps!
Gecko Driver is the link between your tests in Selenium and the Firefox browser
http://toolsqa.com/selenium-webdriver/how-to-use-geckodriver/
I installed gecko driver from github and put it in the folder location of my workplace and it worked!
working result
Download geckodriver and use this code:
System.setProperty("webdriver.gecko.driver", "E:/software and tools/geckodriver.exe");
WebDriver driver= new ChromeDriver();
//Launch the Website
driver.get("http://127.0.0.1:3000");
// Print a Log In message to the screen
System.out.println("Successfully opened the website ");
// Close the driver
driver.quit();

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();

Unable to launch Firefox driver

I have Firefox 11 in my Win7 system with selenium 24.1:
When I tried to launch Firefox using from Eclipse, I got following error(It's same for all even after re installation ):
**Exception in thread "main" java.lang.ExceptionInInitializerError
at org.openqa.selenium.firefox.FirefoxProfile.layoutOnDisk(FirefoxProfile.java:389)
at org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:89)
at org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:246)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:114)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:193)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:186)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:182)
at org.openqa.selenium.fire fox.FirefoxDriver.<init>(FirefoxDriver.java:95)at mend.w.main(w.java:9)
Following is the code, I tried:
package try;
import org.openqa.selenium.firefox.FirefoxDriver;
public class trySelenium {
public static void main(String[] args) {
// TODO Auto-generated method stub
FirefoxDriver n = new FirefoxDriver();
n.get("google.com");
}
}
Since you are using selenium 2.41, it will not support Firefox 11. Either upgrade your browser or downgrade selenium version to respective supported Firefox version.
Instead of using:
FirefoxDriver n = new FirefoxDriver();
use following in your code:
WebDriver n = new FirefoxDriver();
WebDriver is an interface that FirefoxDriver class is implementing.

Resources