I am trying to start opera(v 36.0) using selenium 2.53.0 and Opera chromium driver _win64 (0.2.2).
When I try to run sample code, an exception occurred and browser didn't started.
Sample code:
File pathToOpera = new File("E://operadriver.exe");
DesiredCapabilities cap = DesiredCapabilities.operaBlink();
cap.setCapability("webdriver.opera.driver",pathToOpera);
driver = new OperaDriver(cap);
I am getting error as
java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.opera.driver system property; for more information, see https://github.com/operasoftware/operachromiumdriver. The latest version can be downloaded from https://github.com/operasoftware/operachromiumdriver/releases
at com.google.common.base.Preconditions.checkState(Preconditions.java:199)
at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:109)
at org.openqa.selenium.opera.OperaDriverService.access$0(OperaDriverService.java:1)
at org.openqa.selenium.opera.OperaDriverService$Builder.findDefaultExecutable(OperaDriverService.java:118)
at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:296)
at org.openqa.selenium.opera.OperaDriverService.createDefaultService(OperaDriverService.java:82)
at org.openqa.selenium.opera.OperaDriver.<init>(OperaDriver.java:137)
My execution environment: win 8, 64 bit
Add before Your code:
System.setProperty("webdriver.opera.driver","E://operadriver.exe");
System.setProperty("opera.binary","E://yourOperaPath.exe");
Related
I initiated web driver and try to connect a URL and it returns an exception
What happens is: Open the web browser but does not direct to given Url and print error on the console log.
My code is below:
Webdriver driver = new EdgeDriver();
driver.get("https://learn.microsoft.com/en-us/welcome-to-docs");
Error log:
org.openqa.selenium.WebDriverException: Unable to parse remote response: Unknown error
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:115)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:74)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:136)
I enabled developer mode
I already installed WebDriver using below command in (C:\WINDOWS\system32>):
DISM.exe /Online /Add-Capability /CapabilityName:Microsoft.WebDriver~~~~0.0.1.0
I use the below versions:
selenium version: '3.141.59'
Browser: Microsoft Edge, Version 80.0.361.50 (Official Build)
(64-bit)
os build: 18362.535
Windows Edition: 10 version 1903
Any Idea on this?
DISM.exe /Online /Add-Capability
/CapabilityName:Microsoft.WebDriver~~~~0.0.1.0
Using the above command will install the Microsoft WebDriver for Microsoft Edge Legacy versions 18, it is not available for the Microsoft Edge Version 80.0.361.50 (Official Build) (64-bit).
You could download the related Microsoft Edge WebDriver from Here, based on the Edge version number to download the WebDriver.
Edit:
Try to use the EdgeOptions to set the webdriver path, code as below:
using OpenQA.Selenium.Edge;
using OpenQA.Selenium.Remote;
// EdgeOptions() requires using OpenQA.Selenium.Edge
// Construct EdgeOptions with is_legacy = false
EdgeOptions edgeOptions = new EdgeOptions(false);
edgeOptions.BinaryLocation = #"C:\Program Files (x86)\Microsoft\Edge Beta\Application\msedge.exe";
var msedgedriverDir = #"<download webdriver folder such as:D:\MicrosoftEdgeDriver\edgedriver_win64>";
var msedgedriverExe = #"msedgedriver.exe";
// Construct EdgeDriverService with is_legacy = false too
var service = EdgeDriverService.CreateDefaultService(msedgedriverDir, msedgedriverExe, false);
service.EnableVerboseLogging = true;
var driver = new EdgeDriver(service, edgeOptions);
driver.Navigate().GoToUrl("https://bing.com");
Thread.Sleep(2000);
driver.Close();
More detail information about using Chromium version Edge WebDriver, please check this link:
WebDriver (Chromium)
I face the error cannot focus element. it looks like
i have no idea for fix it, this is what I was did, can anyone help me to fix it?
Try
Dim options As ChromeOptions = FrmWABot.options
options = New ChromeOptions
options.AddArguments("user-data-dir=" & Application.StartupPath & "/profile")
Clipboard.SetText(no)
Dim element As IWebElement = driver.FindElement(By.XPath("//*[#title='Search or start new chat']"))
Clipboard.SetText(no)
With element
.SendKeys(Keys.Control + "v")
.SendKeys(Keys.Enter)
End With
Dim elpesan As IWebElement = driver.FindElement(By.XPath("//*[#id='main']/footer/div[1]/div[2]/div/div[2]"))
With elpesan
Clipboard.SetImage(getImage())
.SendKeys(Keys.Control + "v")
.SendKeys(Keys.Enter)
End With
Dim element1 As IWebElement = driver.FindElement(By.XPath("//*[#id='app']/div[1]/div[1]/div[2]/div[2]/span/div[1]/span/div[1]/div[1]/div[2]/div[1]/span/div[1]/div[2]/div[1]/div[3]/div[2]"))
element1.Click()
With element1
Clipboard.SetText("Happy Birthday...")
.SendKeys(Keys.Control + "v")
.SendKeys(Keys.Enter)
End With
Catch ex As Exception
ex.ToString()
End Try
This error message...
unknown error: cannot focus element (Session info: chrome=77.0.3865.90) (Driver info: chromedriver=2.38.552522
...implies that the ChromeDriver was unable to focus on the WebBrowser i.e. Chrome Browser session.
Your main issue is the incompatibility between the version of the binaries you are using as follows:
You are using chromedriver=2.38
Release Notes of chromedriver=2.38 clearly mentions the following :
Supports Chrome v65-67
Presumably you are using chrome= 77.0
Release Notes of ChromeDriver v77.0 clearly mentions the following :
Supports Chrome version 77
So there is a clear mismatch between the ChromeDriver v2.38 and the Chrome Browser v77.0
Solution
Ensure that:
ChromeDriver is updated to current ChromeDriver v77.0 level.
Chrome is updated to current Chrome Version 77.0 level. (as per ChromeDriver v77.0 release notes)
Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
If your base Web Client version is too old, then uninstall it and install a recent GA and released version of Web Client.
Take a System Reboot.
You can find a relevant discussion in “Message=unknown error: cannot focus element” while executing tests through Selenium, ChromeDriver and Chrome
Try to use action class instead of regular script
Actions action = new Actions(driver);
action.MoveToElement(element).Build().Perform();
I have a grails/groovy project that has one feature that uses selenium standalone server to do some test automation.
I keep getting this error running my grails project in production mode. If I run it directly from IntelliJ it works perfectly so I'm not sure what exactly is wrong.
Here is the relevant code:
WebDriver driver
DesiredCapabilities capability = DesiredCapabilities.chrome()
capability.setBrowserName("chrome")
capability.setPlatform(Platform.WINDOWS)
driver = new RemoteWebDriver( new URL("http://192.168.83.124:4444/wd/hub"), capability);
I'm getting a ClassNotFoundException error on the last line.
In my libraries for the project I'm using selenium-java-2.53.0.jar, selenium-server-standalone-2.53.0.jar and sources has selenium-java-2.53.0-srcs.jar
I have absolutely no idea what's wrong and I've searched the internet exhaustively to find a solution but have found nothing. Any help is appreciated.
Here is the full text of the error:
2017-12-08 15:59:56,381 [http-bio-8080-exec-1] ERROR
errors.GrailsExceptionResolver - ClassNotFoundException occurred when processing request: [GET] /Diversotron-0.1/api/edit
com.google.common.base.Function. Stacktrace follows:
java.lang.ClassNotFoundException: com.google.common.base.Function
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2585)
at java.lang.Class.getDeclaredConstructors(Class.java:1906)
at
org.codehaus.groovy.util.LazyReference.getLocked(LazyReference.java:46)
at org.codehaus.groovy.util.LazyReference.get(LazyReference.java:33)
at diversotron.PropotronService.setPropotron(PropotronService.groovy:25)
at diversotron.ApiController.edit(ApiController.groovy:53)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
It's because Selenium isn't declared in my BuildConfig.groovy file. That's why it ran via IntelliJ but not in production. Doing a grails prod war will not include the libraries. They have to be specified in the buildconfoig.groovy file.
I had to add these lines.
def seleniumVersion = "2.53.0"
and in dependencies I had to add this:
runtime "org.seleniumhq.selenium:selenium-chrome-driver:$seleniumVersion"
Hopefully this will help someone else down the line!
Map chrome Options = new Map();
ChromeOptions.put("binary","/use/lib/chromium-browser/chromium-browser");
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);
Web Driver driver = new Chrome Driver(capabilities);
try this
I am new on using Selenium and I faced some questions on using RemoteWebDriver in Selenium Grid 2. I would like to what's wrong in my code. Thanks.
I set the RemoteWebDriver in 3 steps:
Set the Chrome driver to system property, I checked the path is correct.
Set the capabilities
Turn on the driver by RemoteWebDriver
logger.info("1. Start");
File file = new File("/path/of/chromedriver");
System.setProperty("webdriver.chrome.driver", file.getAbsolutePath());
logger.info("2. Get Path: " + file.getAbsolutePath());
DesiredCapabilities caps = new DesiredCapabilities();
caps.setBrowserName(DesiredCapabilities.chrome().getBrowserName());
logger.info("3. Set capabilities: " + caps);
URL url = new URL(URL);
RemoteWebDriver driver = new RemoteWebDriver(url, caps);
logger.info("4. Initialize driver: " + driver);
logger.info("5. End");
return driver;
The result pass first 2 steps but fail in the last step because the log does not show. It seems there is a problem in setting RemoteWebDriver. The log is shown as below:
May 16, 2017 8:28:16 PM com.test.Setup setupDriver
INFO: 1. Start
May 16, 2017 8:28:16 PM com.test.Setup setupDriver
INFO: 2. Get Path: /path/of/chromedriver
May 16, 2017 8:28:16 PM com.test.Setup setupDriver
INFO: 3. Set capabilities: Capabilities [{browserName=chrome}]
May 16, 2017 8:28:16 PM com.test.Setup setupDriver
SEVERE: java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://chromedriver.storage.googleapis.com/index.html
Can anyone suggest where is the problem, thanks!
selenium-server-standalone-3.4.0.jar
selenium-java-3.4.0
chromedriver 2.29
java version "1.8.0_111"
TestNG
The exception says it all.
May 16, 2017 8:28:16 PM com.test.Setup setupDriver SEVERE: java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.chrome.driver system property; for more information, see https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://chromedriver.storage.googleapis.com/index.html
Please ensure you do the following on the machine in which you are running the node.
Have the location of the chromedriver binary made available as part of your PATH environment variable.
Now to ensure that the location is properly set, open up a new command prompt/terminal and type chromedriver.
You should see an output as below (my output is from a MAC)
12:16 $ chromedriver
Starting ChromeDriver 2.29.461585 (0be2cd95f834e9ee7c46bcc7cf405b483f5ae83b) on port 9515
Only local connections are allowed.
Once you see a similar output, you can try running your test again and you should be fine.
I am trying to run my test cases on Chrome and I had copied the path in the Properties file,but still console is throwing annoying statements like:
ERROR: The path to the chromedriver executable must be set by the webdriver.chrome.driver system property; for more information, see http://code.google.com/p/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://code.google.com/p/chromium/downloads/list
FAILED CONFIGURATION: #BeforeTest startWebSession
java.lang.NullPointerException
One thing I have found is that the Chrome driver cannot be started from within Eclipse. It must be run from a command prompt. At least on Windows 7 64-bit.
Trying to run it from within Eclipse produces this exception:
Exception in thread "main" java.lang.IllegalStateException: The webdriver.chrome.driver system property defined chromedriver executable does not exist: C:\Windows\System32\chromedriver.exe
This problem only occurs for Chrome. IE and FireFox work fine from within Eclipse.
Download the chrome driver from http://code.google.com/p/chromedriver/downloads/list
Initialize your driver object in the following manner -
System.setProperty("webdriver.chrome.driver","C:\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
By doing this the chrome driver works properly.
This is how do I initialize the ChromeDriver:
public RegulationUI() throws Exception{
ChromeDriverService service = ChromeDriverService.createDefaultService();
File file = new File(RegulationUI.class.getResource("/chromedriver.exe").toURI());
System.setProperty(ChromeDriverService.CHROME_DRIVER_EXE_PROPERTY, file.getAbsolutePath());
ChromeOptions options = new ChromeOptions();
options.addArguments("--start-maximized");
driver = new ChromeDriver(service,options);
}
BTW my test class is named RegulationUI
Try this, it works for me and moreover, I know that this is "multicomputer" solution - our project is in subversion and this way everybody can run it, even if we have differently setup where exactly on disk the "working folder" for IDE is
Please download chromedriver.exe for Google chrome browser
please download IEdriver.exe for Internet explore.
Please And kept these files in a root folder of windows for simplicity. Lets consider your operating systems installed on c:\ (C Driver) create a folder name Selenium on C-Drive and Kept these binary(.exe) files. like c:\selenium
in your Testcase/testScript Write as
//For Chrome Browser:
Webdriver driver = new ChromeDriver();
java.io.File file = new File("c:\\selenium\\chromedriver.exe");
System.setProperty("webdriver.chrome.driver", file.getAbsolutePath());
If you are using maven then try to use following in your pom:
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>RELEASE</version>
</dependency>
and use it like this for chrome in your setup:
ChromeDriverManager.getInstance().setup();
driver = new ChromeDriver();