I am pretty new to Selenium world. I have been stuck with this code of opening a basic facebook page and it keeps throwing an error saying:
Starting ChromeDriver 78.0.3904.105
(60e2d8774a8151efa6a00b1f358371b1e0e07ee2-refs/branch-heads/3904#{#877})
on port 8852 Only local connections are allowed. Please protect ports
used by ChromeDriver and related test frameworks to prevent access by
malicious code. Exception in thread "main"
org.openqa.selenium.WebDriverException: unknown error: cannot find
Chrome binary Build info: version: '3.141.59', revision: 'e82be7d358',
time: '2018-11-14T08:25:48' System info: host: 'ATLMD2226268', ip:
'10.7.0.108', os.name: 'Windows 10', os.arch: 'amd64', os.version:
'10.0', java.version: '1.8.0_211'
Code I am using is:
package NewPackage;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
public class MyClass {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", "C:\\Users\\vaaggarw\\Downloads\\chromedriver_win32\\chromedriver.exe");
ChromeOptions options = new ChromeOptions();
options.setBinary("C:\\Program Files (x86)\\Google Chrome (Local)\\chrome.exe");
WebDriver driver = new ChromeDriver();
String baseUrl = "http://www.facebook.com";
String tagName = "";
driver.get(baseUrl);
tagName = driver.findElement(By.id("email")).getTagName();
System.out.println(tagName);
driver.close();
System.exit(0);
}
}
make sure all selenium jars are not missing in your project. If not delete them anyway and add new jars from fresh download
clean your project
as pcalkins advises, use the chrome options propertly
Related
We have a set of Selenium auto tests that work with Chrome/Firefox/Edge (pre Chromium Edge). We would like to be able to run the set test suite against the latest edge.
Selenium (Java) - 4.0.0-alpha-4
Edge - 79.0.309.71
I've tried various combinations of the below setup
System.setProperty("webdriver.edge.edgehtml", "false");
System.setProperty("webdriver.edge.driver", "path\to\msedgedriver.exe");
System.setProperty("webdriver.chrome.driver", "path\to\msedgedriver.exe");
EdgeOptions edgeOptions = new EdgeOptions();
edgeOptions.setBinary("path\to\msedgedriver.exe");
driver = new EdgeDriver();
Each time gives the following error
org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start.
Build info: version: '4.0.0-alpha-4', revision: 'c2d955b49e'
System info: os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_162'
Driver info: driver.version: EdgeDriver
Has anyone got this working?
I test with Microsoft Edge(Chromium) Beta version 79.0.309.43 and the same version of Microsoft Edge(Chromium) WebDriver (You could download the webdriver from here) and it works. You could refer to the code below and change the path to your owns:
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.edge.EdgeOptions;
public class Edgeauto {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", "your\\path\\to\\edge\\webdriver\\msedgedriver.exe");
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.setBinary("C:\\Program Files (x86)\\Microsoft\\Edge Beta\\Application\\msedge.exe");
EdgeOptions edgeOptions = new EdgeOptions().merge(chromeOptions);
WebDriver driver = new ChromeDriver(edgeOptions);
driver.get("https://www.google.com/");
}
}
Also please remember to have the location of Edge Beta and msedgedriver.exe on your PATH.
Not sure if this will be relevant for everyone, but I have fixed it myself by doing the following...
The version of edge is Version 79.0.309.71 (Official build) (64-bit) and i assumed the correct driver was the the 64 bit driver from the microsoft site.
HOWEVER, I then tried the 32 bit driver and it worked as expected...
System.setProperty("webdriver.edge.driver", "path\to\msedgedriver_32.exe");
driver = new EdgeDriver();
Below code I written to open www.google.com under selenium standalone Grid environment. During the execution it shows error
CONFIGURATION:
OS: WINDOWS 10
BROWSER : FireFox (66.0.3)
Selenium Standalone Command:
java -Dwebdriver.gecko.driver=C:\eClipse\jar\Selenium\geckodriver\geckodriver.exe -jar selenium-server-standalone-3.141.59.jar -role standalone
ERROR:
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Unable to find a matching set of capabilities
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'QAT2', ip: '10.1.6.79', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_91'
Driver info: driver.version: unknown
I try to google this exception but not find any clue to solve it. Can I have any solution for this.
CODE:
public class GridSetup {
private String baseUrl ;
private String nodeURL ;
public WebDriver wDriver ;
public static void main() throws MalformedURLException{
baseUrl = "http://www.google.com";
nodeURL = "http://localhost:4444/wd/hub";
System.setProperty("webdriver.gecko.driver","C:\\eClipse \\geckodriver.exe");
DesiredCapabilities caps = DesiredCapabilities.firefox();
System.out.println( "#####################");
caps.setBrowserName("firefox");
caps.setCapability("marioneete", true);
caps.setPlatform(Platform.WIN10);
caps.setVersion("66.0.3");
wDriver = new RemoteWebDriver(new URL(nodeURL), caps);
wDriver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
wDriver.get(baseUrl);
}
}
This error message...
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Unable to find a matching set of capabilities
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'QAT2', ip: '10.1.6.79', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_91'
Driver info: driver.version: unknown
...implies that the GeckoDriver was unable to initiate/spawn a new WebBrowsing Session i.e. Firefox Browser session.
Your main issue is the incompatibility between the version of the binaries you are using as follows:
Your Selenium Client version is 3.141.59.
Your JDK version is 1.8.0_91 which is pretty ancient.
So there is a clear mismatch between the JDK v8u91 , Selenium Client v3.141.59.
Solution
Upgrade JDK to recent levels JDK 8u202.
I am new to selenium.
In below code firefox is being launched but i am unable to make any entry in the textbox.
package webdrivers;
import java.sql.Driver;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.remote.server.handler.SendKeys;
public class Automation
{
public static void main(String[] args)
{
WebDriver driver = new FirefoxDriver();
driver.get("https://www.facebook.com/");
driver.findElement(By.name("email")).sendKeys("your_username");
}
}
Error is:-
Exception in thread "main" org.openqa.selenium.InvalidArgumentException: Expected [object Undefined] undefined to be a string Build info: version: 'unknown', revision: '5234b32', time: '2017-03-10 09:00:17 -0800' System info: host: 'RAHUL', ip: '192.168.1.109', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_121' Driver info: org.openqa.selenium.firefox.FirefoxDriver Capabilities [{moz:profile=C:\Users\lenovo\AppData\Local\Temp\rust_mozprofile.cduJLZVQoFth, rotatable=false, timeouts={implicit=0, pageLoad=300000, script=30000}, pageLoadStrategy=normal, platform=ANY, specificationLevel=0, moz:accessibilityChecks=false, acceptInsecureCerts=false, browserVersion=53.0, platformVersion=6.3, moz:processID=6184, browserName=firefox, platformName=windows_nt}] Session ID: 452dde13-0981-4d4d-bb9a-beb6739485d5
To work with Selenium 3.4.0 you need to download gecko driver v0.16.0 or higher from here and save it. Upgrade your Mozila Firefox to 53.x
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 helps you.
Try this way..Download gecko_driver from this link
Note:- If your dealing with latest gecko driver version(v0.16.0), make sure your firefox browser is updated to latest version(V53).
Update selenium jar files as well as. you can download selenium latest jar files from this link
System.setProperty("webdriver.gecko.driver", "C:\\Drivers\\geckodriver.exe"); // Your gecko_driver path.
WebDriver driver = new FirefoxDriver();
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
driver.get("https://www.facebook.com");
driver.findElement(By.name("email")).sendKeys("Username");
This is an ongoing issue with geckodriver:
https://github.com/mozilla/geckodriver/issues/659
If you still want to work with firefox : you can downgrade firefox to v52 and then along with geckodriver v0.15 you'll be able to work fine.
I am fairly new to selenium and trying to invoke the Firefox browser using the following java code.
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class google {
public static void main(String[] args) throws InterruptedException {
// TODO Auto-generated method stub
System.setProperty("webdriver.gecko.driver", "/Users/gowtham/Desktop/Selenium/geckodriver");
WebDriver driver = new FirefoxDriver();
driver.get("http://google.com");
Thread.sleep(1000);
driver.quit();
}
}
When I run the above code, I get the following exception on my console.
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session. desired capabilities = Capabilities [{marionette=true, browserName=firefox, moz:firefoxOptions=org.openqa.selenium.firefox.FirefoxOptions#7d70d1b1, version=, platform=ANY, firefox_profile=org.openqa.selenium.firefox.FirefoxProfile#2a742aa2}], required capabilities = Capabilities [{}]
Build info: version: 'unknown', revision: '86a5d70', time: '2017-02-16 07:47:51 -0800'
System info: host: 'system', ip: 'fe80:0:0:0:2acf:e9ff:fe19:261%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.11.6', java.version: '1.8.0_45'
Driver info: driver.version: FirefoxDriver
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:91)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:141)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:241)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:128)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:293)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:272)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:267)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:263)
at org.openqa.selenium.firefox.FirefoxDriver.<init>(FirefoxDriver.java:122)
at HelloWorls.google.main(google.java:11)
I have firefox v52.0 installed on my machine.
Please share your thoughts on this issue.
I can't add comments so far, so post the way to resolve this problem here.
Indeed, gecko driver version needs to be downgraded.
For those, who are using 'bonigarcia-webdrivermanager', add driver version explicitly before instantiating FirefoxDriver:
FirefoxDriverManager.getInstance().setup("0.14.0");
I am receiving the following exception for my java code. All I want to do is open up a chrome browser. I have downloaded the proper chrome driver and stuck it in my google chrome folder under program files x86. Right now what happens is, the browser opens and then immediately says that the program has stopped working and then It throws the exception once I click exit on the window.
Starting ChromeDriver 2.20.353145 (343b531d31eeb933ec778dbcf7081628a1396067) on port 23239
Only local connections are allowed.
Exception in thread "main" 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.
Build info: version: '2.53.0', revision: '35ae25b', time: '2016-03-15 16:57:40'
System info: host: 'W7LPC01TDFU', ip: '10.95.7.58', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_79'
Driver info: driver.version: ChromeDriver
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:665)
here is my code so far
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
public class mainTester {
public static void main(String[] args) throws InterruptedException{
setUp();
}
public static void setUp() throws InterruptedException {
// Optional, if not specified, WebDriver will search your path for chromedriver.
System.setProperty("webdriver.chrome.driver", "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("http://www.google.com/xhtml");
Thread.sleep(5000); // Let the user actually see something!
WebElement searchBox = driver.findElement(By.name("q"));
searchBox.sendKeys("ChromeDriver");
searchBox.submit();
Thread.sleep(5000); // Let the user actually see something!
System.out.println("Finished");
driver.quit();
}
}
Do you know what version of Chrome you are using? Chances are the latest since Google likes to autoupdate. You should be using the latest version of Chromedriver. The traceback you posted says you are using version 2.20 (Starting ChromeDriver 2.20.353145 (343b531d31eeb933ec778dbcf7081628a1396067) on port 23239). The latest is 2.25 which Supports Chrome v53-55