Having issues with firefox driver or chrome driver for selenium - java

For ex my chrome when dropped in the commpand prompt gives me the path
- /Applications/Google\ Chrome.app
I set
System.setProperty("webdriver.chrome.driver", "/Applications/Google/Chrome.app");
WebDriver driver = new ChromeDriver();
driver.get("http://www.google.com");
But it doesnt work, same with firefox. I used a lot of suggestions already given but none seems to work. Can someone pls let me know if there is something to be added?

Why have you used "/Applications/Google/Chrome.app". You would need to provide the path of the driver only, not the browser. Below is the code for Firefox, but you would need to download and configure GeckoDriver (for latest version of FF and Selenium 3.x)
public class FirefoxTest {
#Test
public void FirefoxTest_Test1() {
System.setProperty("webdriver.gecko.driver","D:\\Firefox\\geckodriver.exe");
FirefoxDriver driver = new FirefoxDriver();
driver.get("http://www.google.com");
}
}
Check this link for complete details for downloading and setup of Geckodriver with Firefox - http://automationtestinghub.com/selenium-3-0-launch-firefox-with-geckodriver/

For Chrome: Need to Download fresh Chrome Driver from http://chromedriver.storage.googleapis.com/index.html?path=2.24/
and mention local system path up to chomedriver.exe
System.setProperty("webdriver.chrome.driver","G:\\ravik\\Ravi-Training\\Selenium\\Drivers\\cd\\chromedriver.exe");
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
ChromeDriver d1 = new ChromeDriver(capabilities);
For FF: if your firefox version is latest(46.0 or above) then user geckodriver along with selenium 2.53.0 jar files. download geckodriver form https://github.com/mozilla/geckodriver/releases and then save it as "wires" in your local system. mention local system path up to wires.
System.setProperty("webdriver.gecko.driver", "G:\\ravik\\Ravi-Training\\Selenium\\Marionette for firefox\\wires.exe");
WebDriver driver = new MarionetteDriver();
Hope this could be helpful.

The easiest way to use chrome driver is.. download and place the driver into the bin folder of your project. no need to set the path of the driver location

Related

which chromedriver version supports electron app?

I try to run electron app using the following code:
#Test
public void testElectron() {
System.setProperty("webdriver.chrome.driver", chromeDriverPath);
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.setBinary(this.electronPath);
WebDriver driver = new ChromeDriver(chromeOptions);
}
But I get the following error:
Starting ChromeDriver 87.0.4280.88 (89e2380a3e36c3464b5dd1302349b1382549290d-refs/branch-heads/4280#{#1761}) on port 37592
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
org.openqa.selenium.SessionNotCreatedException: session not created: This
version of ChromeDriver only supports Chrome version 87
Current browser version is 80.0.3987.165 with binary path src\main\resources\electron\electronApp.exe
Is there a specific chromedriver the is suitable for electron app (for selenium java)?
This error message...
Current browser version is 80.0.3987.165 with binary path src\main\resources\electron\electronApp.exe
...implies that the Chrome browser version is 80.0.
Solution
So as a solution you have to download the matching ChromeDriver
from ChromeDriver v80.0.3987.106 repository.

unable to run the HtmlUnit Driver with selenium Webdriver using java

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

Facing issue regarding Selenium(with java) and Firefox connectivity

Error: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms.
Before all scripts were working fine..but now every script has stopped working.
I have updated Selenium version 3.0.1.(updated jar files), updated Firefox version 52.0.2 ...java version 8.
Please suggest what I am missing?
with Geckodriver version v0.15 , you have to use selenium 3.3.1
You would need to provide firefox binary location. One way of doing it is by the below code -
FirefoxOptions options = new FirefoxOptions();
options.setBinary("C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe"); //Location where Firefox is installed
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability("moz:firefoxOptions", options);
FirefoxDriver driver = new FirefoxDriver(capabilities);
driver.get("http://www.google.com");
More info here - http://www.automationtestinghub.com/selenium-3-0-launch-firefox-with-geckodriver/
For Selenium 2.x later versions need to maintain geckodriver for firefox browser and if you find same issue then add binary path to your driver instance and try again.
Reference:
selenium 2.53.0 with firefox 46

How can I start installed browser without adding IE driver or Chrome driver in selenium web driver?

I have installed IE and chrome browser in my computer. I want to run my selenium script from original browser with all add-ons and default setting.
I am able to find *.exe of browser with some capabilities.But can not able to write and open link (driver.get()) in browser. Please refer following code.
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
cap.setCapability(InternetExplorerDriver.INITIAL_BROWSER_URL, DriverTestNG.url);
DesiredCapabilities.internetExplorer().setCapability("ignoreProtectedModeSettings", true);
System.setProperty("webdriver.ie.driver", "src/main/resources/Framework/Drivers/Windows/IEDriverServer_Win32_2.40.0/IEDriverServer.exe");
cap.setCapability("IE.binary", "C:\\Program Files\\Internet Explorer\\iexplore.exe");
cap.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
cap.setJavascriptEnabled(true);
cap.setCapability("requireWindowFocus", true);
cap.setCapability("enablePersistentHover", false);
cap.setCapability("elementScrollBehavior", 1);
cap.setCapability("cssSelectorsEnabled", true);
cap.setCapability("nativeEvents", true);
driver = new InternetExplorerDriver(cap);
May be I have missed something.I am not sure about this that selenium web driver supports this functionality or not.
Please guide me for it.
Thanks in advance.
Regarding to your title, you can not run Internet Explorer or Chrome without using a webDriver because you need the webDriver as an API to access the functionality of IE or chrome.
But you can still use extensions and your default settings. The reason why you don't see any extensions running chromeDriver is that it always creates a new temporary profile for each test-session. If you want to run your own custom profile with extensions and settings you have to tell chromeDriver which user profile it should use by defining the user-data-dir.
You can find the capabilities here:
https://sites.google.com/a/chromium.org/chromedriver/capabilities
example:
ChromeOptions options = new ChromeOptions();
options.addArguments("user-data-dir=C:/Users/user_name/AppData/Local/Google/Chrome/User Data");
You can also specifiy extensions by using:
https://sites.google.com/a/chromium.org/chromedriver/extensions
I don't use IEdriver so I can't tell you how it works with the IE but as far as i know the internet explorer does not have profiles and the extensions are managed somewhere in the registry. So I would assume that extensions installed before running the tests are available also trough IEWebDriver.

How to open chrome in Selenium webdriver?

I'm trying to launch chrome with Selenium Webdriver and used the following code:
System.setProperty("webdriver.chrome.driver",
"C:/Program Files (x86)/Google/Chrome/Application/chrome.exe");
WebDriver driver = new ChromeDriver();
driver.get("http://www.yahoo.com");
Chrome browser opens but is not proceeding further. What could be the reason for the following error:
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.
You are incorrectly starting up the driver
webdriver.chrome.driver is supposed to be the path to the driver that you've downloaded and not Chrome's physical location.
First you need to download chrome driver file from this link and than import its JAR to the package in eclipse.
Download the link from here
Then you will have to import it in your program.
import org.openqa.selenium.chrome.ChromeDriver;
and than make a driver instance
driver = new ChromeDriver();
Download the external JAR of chrome
In eclipse :: right click on the respective package(in the package explorer) and click on the properties. Go to Java build path and add external jars. Now add the jar file of chrome . and than follow the steps i wrote in the ans which was to import the chrome driver and creating an instance
Follow these steps in the photograph.
1)
select your file from here and right click
Below snippet shows how you can open chrome browser using selenium webdriver.
public static void main(String[] args) {
//Creating a driver object referencing WebDriver interface
WebDriver driver;
//Setting the webdriver.chrome.driver property to its executable's location
System.setProperty("webdriver.chrome.driver", "/lib/chromeDriver/chromedriver.exe");
//Instantiating driver object
driver = new ChromeDriver();
//Using get() method to open a webpage
driver.get("https://stackoverflow.com");
//Closing the browser
driver.quit();
}
Use the latest versions of ChromeDriver.
Source|
http://chromedriver.storage.googleapis.com/index.html
You need to setup your browser settings first. Try below-mentioned code if it helps:
public void setup ()
{
System.setProperty("webdriver.chrome.driver", "C:\\**PATH**\\chromedriver.exe");
ChromeOptions options = new ChromeOptions();
options.addArguments("test-type");
options.addArguments("start-maximized");
options.addArguments("--js-flags=--expose-gc");
options.addArguments("--enable-precise-memory-info");
options.addArguments("--disable-popup-blocking");
options.addArguments("--disable-default-apps");
options.addArguments("test-type=browser");
options.addArguments("disable-infobars");
driver = new ChromeDriver(options);
driver.manage().deleteAllCookies();
}
You'll need to import files by hovering on error lines.

Categories

Resources