I am using ant to run my selenium test, and I have this message (see pic):
[junit] Error
[junit] Starting ChromeDriver (v2.xxxxx) on port xxxx
I tried the following properties but without success :
options.addArguments("--disable-logging");
options.addArguments("--ignore-certificate-errors");
options.addArguments("--silent");
I can disable this message? it's possible ?
I suggest:
ChromeOptions chromeOptions = setupChromeOptions();
System.setProperty("webdriver.chrome.logfile", "\\path\\chromedriver.log");
System.setProperty("webdriver.chrome.driver", "\\path\\chromedriver.exe");
System.setProperty("webdriver.chrome.args", "--disable-logging");
System.setProperty("webdriver.chrome.silentOutput", "true");
driver = new ChromeDriver(chromeOptions);
because
1) This way works for me and
2) the often-reccomended ChromeDriverService.Builder() throws a compile error for me.
This works for me with the following config
selenium-chrome-driver-2.48.2.jar
chromedriver 2.20
selenium-java-2.48.2.jar
We need to pass --silent argument to chromedriver to stop console message. We can achieve this using 'withSilent(true)' method
Launch chromedriver using chromedriverservice as shown in below sample code
Sample Code:
ChromeDriverService cdservice=new ChromeDriverService.Builder().usingDriverExecutable(new File("/path/to/chromedriver.exe"))
.withLogFile(new File("/path/to/chromedriver.log"))
.withSilent(true)
.usingAnyFreePort()
.build();
WebDriver driver = new ChromeDriver(cdservice);
driver.get("http://www.google.com");
Related
I am using selenium chrome driver with version 3.6.0
and using google-guava 23.0.
When i do this :
ChromeOptions chromeOptions = new ChromeOptions();
It gives following error :
java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkState(ZLjava/lang/String;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V
at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:124)
at org.openqa.selenium.chrome.ChromeDriverService.access$000(ChromeDriverService.java:32)
at org.openqa.selenium.chrome.ChromeDriverService$Builder.findDefaultExecutable(ChromeDriverService.java:137)
at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:329)
at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:88)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:157)
I also checked this : https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-chrome-driver/3.6.0
Can anyone help me what version of guava should i use here ?
Code :
System.setProperty("webdriver.chrome.driver", driverPath);
log.warn("chrome driver path is : {}", driverPath);
List<String> options = proxyConfig.getChromeOptions();
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments(options);
Map<String, String> capabilites = proxyConfig.getCapabilities();
for(Map.Entry<String, String> entry : capabilites.entrySet()) {
chromeOptions.setCapability(entry.getKey(), entry.getValue());
}
return new ChromeDriver(chromeOptions);
It is not clear from your question about your particular usecase why you are trying to signal out Selenium Client v 3.6.0 and google-guava 23.0 individually.
To keep it simple,
Selenium Client v 3.6.0 uses guava v23.0
Release Notes of Selenium Client v 3.5.1 clearly mentions the following :
Bump guava to version 23.
So, I don't see any issue out there.
However, as an end user instead of selecting individual jars from multiple selenium-java-X.Y.Z.zip releases user should consider completely removing all the Selenium related jars from the older build and replace with the new jars from the new build.
This particular issue
This error message...
java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkState(ZLjava/lang/String;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V
...implies that the Java Client was unable to find ChromeDriver()
It will be tough to analyze the real issue in absence of your code trials. However as per java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkState(ZLjava/lang/String;) with Selenium, gradle and ChromeDriver you need to use the System.setProperty() line to set the ChromeDriver binary path (not the chrome binary path). For that you have to download the ChromeDriver binary from the ChromeDriver - WebDriver for Chrome and place it in your system and mention the absolute path of the ChromeDriver through System.setProperty() line. Hence you have to use the line :
System.setProperty("webdriver.chrome.driver", "C:\\path\\to\\chromedriver.exe");
ChromeOptions chromeOptions = new ChromeOptions();
// configurations through chromeOptions
WebDriver driver = new ChromeDriver(chromeOptions );
I'm trying to launch my electron executable using selenium and java in a windows environment but I get a timeout error.
The code that I'm using is something like this:
System.setProperty("webdriver.chrome.driver", "C:\\chromedriver.exe");
ChromeOptions opt = new ChromeOptions();
opt.setBinary("C:\\Users\\myUser\\MyApp\\MyApp.exe");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("chromeOptions", opt);
WebDriver driver = new ChromeDriver(capabilities);
When previous code is executed, my application is launched but I can't continue with my test because I get this error from selenium:
org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: exited normally
(Driver info: chromedriver=2.33.506120,platform=Windows NT 10.0 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 61.21 seconds
......
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:159)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:142)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:637)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:250)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:236)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:137)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:184)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:148)
I have tried with different versions of chromedriver and selenium but It doesn't work. Does anyone know what could be the problem?
Note: The error is thrown when this line is executed within HttpCommandExecutor class:
ProtocolHandshake.Result result = handshake.createSession(client, command);
You need to define chromeDriver args for your application path. I'm sharing my code with you. Hope to help.
ChromeOptions options = new ChromeOptions();
options.setBinary(binaryPath);
options.addArguments("--app=" + argPath);
options.setCapability("chromeOptions", options);
driver = new ChromeDriver(options);
This is the code :
And error :
I am trying to run the script in headless browser but it gives the error as mentioned in screenshot.
I will suggest to use phantomjs instead of HTMLUnit driver for headless automation
Now if you want to use headless with phantomjs. download the stable build of phantomjs for your headleass jobs. download it from below link :-
http://phantomjs.org/download.html
Now add System.setPropertybefore driver instance
DesiredCapabilities caps = new DesiredCapabilities();
caps.setJavascriptEnabled(true); // not really needed: JS enabled by default
caps.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY, "C:/phantomjs.exe");
WebDriver driver = new PhantomJSDriver(caps);
refer the link below for more info :-
http://seleniumworks.blogspot.in/2013/03/headless-browser-testing-using.html
I'm trying to run my Java selenium tests using Opera (version 31). I'm using last version of Selenium Webdriver (2.47.1) and last version of OperaChromiumDriver (0.2.2).
I've tried to use next method to instantiate Opera:
System.setProperty("webdriver.chrome.driver", "\\path\\to\\my\\operadriver.exe");
WebDriver driver = new ChromeDriver();
And i've tried another method with RemoteWebdriver:
DesiredCapabilities capabilities = DesiredCapabilities.opera();
ChromeOptions options = new ChromeOptions();
options.setBinary("/path/to/opera");
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
WebDriver driver = new RemoteWebDriver(new URL("http://127.0.0.1:9515"),capabilities);
(these methods are described in answers to this question: How to use OperaChromiumDriver for opera version >12.X)
Both methods have the same problem.
Opera opens, but then crushes with next exception:
org.openqa.selenium.SessionNotCreatedException: session not created exception from disconnected: Unable to receive message from renderer
(Session info: Opera with embedded Chromium 0.1889.230)
(Driver info: OperaDriver=0.2.0 (ba47709ed9e35ce26dbd960fb5d75be104290d96),platform=Windows NT 6.1 x86_64
(WARNING: The server did not provide any stacktrace information)
Firefox, Chrome and IE drivers work as it should be, i have such problem only with OperaChromiumDriver.
Can anyone help me with this issue?
Try to instantiate OperaDriver like this instead:
File operaFile = new File("\\path\\to\\my\\operadriver.exe");
System.setProperty("webdriver.opera.driver", operaFile.getAbsolutePath());
WebDriver driver = new OperaDriver();
In my application, .getAbsolutePath() works but just specifying the path in .setProperty does not. No idea why, since the string output of either is identical.
Unfortunately I am still unable to use OperaDriver in my tests because it becomes unresponsive after loading a few pages. This occurs on 3 different machines running different versions of Windows and returns only this error:
[SEVERE]: Timed out receiving message from renderer:
FirefoxDriver, ChromeDriver, and InternetExplorerDriver all work fine with my tests, so, whatever.
This command didn't launch opera. thrown error "Runner threw exception on construction".
driver=new OperaDriver();
driver.get("url");
Even this didn't launch opera but thrown same error "Runner threw exception on construction".
System.setProperty("webdriver.opera.driver", "path of OperaDriver.exe");
driver=new OperaDriver();
driver.get("url");
This didn't launch opera thrown error "Could not start Opera: launcher unable to start binary".
DesiredCapabilities capabilities = DesiredCapabilities.opera(); //in this command opera is stroked.
capabilities.setCapability("opera.binary", "path of OperaDriver.exe");
driver = new OperaDriver(capabilities);
But by using the 2nd and 3rd step codes with the following path "C:\Program Files\Opera\launcher.exe", opera LAUNCHED but URL/website didn't open in the browser.
try this:
Separate OperaDriver
You can also use OperaDriver as a standalone dependency in your project. Download the package from the Github project's download section and extract it to a location of your choice. For your own projects include the lib/ directory on your classpath, for example:
javac -classpath "lib/*:." Example.java
you can also refer the selenium wiki for opera here once.
I used this and it worked.
System.setProperty("webdriver.chrome.driver", "C:\\Users\\Devi\\Downloads\\operadriver_win32\\operadriver.exe");
driver =new ChromeDriver();
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");