Firefox not opening the specified URL when I run my webdriver program - selenium

I am new to automation with selenium and trying to run a basic program to launch Firefox and open Google.com. But I get Firefox launched with "about:blank&utm_content=firstrun" Please help. Am on Windows 10 and Firefox version is: 48.0 (latest). I have the latest Selenium drivers and JRE versions too.
Here is my code:
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class GoogleTest {
public static void main(String[] args) {
WebDriver driver = new FirefoxDriver();
driver.get("http://google.com");
}
}

Related

MSEdge Driver not launching Brwoser using selenium

I am using selenium to automate MS Edge (chromium) browser. I have downloaded correct driver i.e v79.0.309.43 which is same for driver and browser.
but when I run code , it simply shows message that it is launching on multiple ports .See Screenshot below=
Can someone point out what is issue here?
Thanks,
Nilesh
I test with Microsoft Edge(Chromium) Beta version 79.0.309.43 and the same version of Microsoft Edge(Chromium) WebDriver 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.

Chromebrowser show "data:," instead of the parameter passed in selenium

I am trying to run a simple URL to get started in chrome browser but getting just "data:,"My JDK ,selenium and browser are all latest version.
Chrome browser used - Version 76.0.3809.100(32 - Bit)
Java - JDK 1.8
Chromedriver used - ChromeDriver 76.0.3809.126
Code used
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
//import org.openga.selenium.Webdriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
public class CLMTWorkflow {
public static void main(String[] args) {
//System.setProperty("webdriver.ie.driver","H:\\Selenium Prerequisite\\Executables\\IEDriverServer.exe");
//InternetExplorerDriver driver = new InternetExplorerDriver();
//System.setProperty("webdriver.gecko.driver", "H:\\Selenium Prerequisite\\Executables\\geckodriver.exe");
//FirefoxDriver driver = new FirefoxDriver();
System.setProperty("webdriver.chrome.driver", "H:\\Selenium Prerequisite\\Executables\\chromedriver.exe");
ChromeDriver driver = new ChromeDriver();
driver.get("https://www.myntra.com/");
}
}

Chrome browser version - 72.0.3626.121 not opening with selenium

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import init.Constants;
public class TestSelenium {
private static WebDriver driver;
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", System.getProperty("user.dir")+Constants.getChromeDriver());
driver = new ChromeDriver();
driver.get("https://www.google.com");
}
}
I am getting the error as below
Starting ChromeDriver 2.46.628402 (536cd7adbad73a3783fdc2cab92ab2ba7ec361e1) on port 45163
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
The chrome browser is opening but the url is not coming up.
I am using
Chrome driver - 72.0.3626.69
WebDriver - 3.0
You can use bonigarcia dependency for your automation. Then you don't need to keep chromedriver.exe or setting up system variables. It will do all the configurations automatically for all the platforms and all the browsers as well.
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>3.3.0</version>
</dependency>
Below is a sample class to get chrome browser instance. You can modify this class as per your requirement.
import io.github.bonigarcia.wdm.*;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class DriverFactory {
public static WebDriver getDriver() {
WebDriverManager.chromedriver().setup();
return new ChromeDriver();
}
}
I have tested this with Selenium 3.14.0 and Chrome Version 73.0.3683.86 (Official Build) (64-bit)
You mentioned using Chrome driver - 72.0.3626.69 but error shows Starting ChromeDriver 2.46.628402. Check if you have correct chrome driver.
The possible reasons:
Old selenium (download 3.14.xx from https://www.seleniumhq.org/download/)
older chrome driver (consider update to the latest chromedriver https://chromedriver.storage.googleapis.com/index.html?path=73.0.3683.68/)
Chrome browser version mismatch (check the browser version and chromedriver compatibility at https://sites.google.com/a/chromium.org/chromedriver/downloads/version-selection)
Older Java version (latest Java version 11.0.2)
it does not open because you have not specify the path of the chromedriver.exe file
please find the below code snippet.
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class TestChrome {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", "path of the exe file\\chromedriver.exe");
// Initialize browser
WebDriver driver = new ChromeDriver();
// Open facebook
driver.get("http://www.facebook.com");
// Maximize browser
driver.manage().window().maximize();
}
}
Try to first set the Chrome driver path before calling the Chrome driver.
System.setProperty("webdriver.chrome.driver", "path of the exe file\\chromedriver.exe");
driver = new ChromeDriver();
driver.get("https://www.google.com");
Try to set chrome options:
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments("--whitelist-ip *");
chromeOptions.addArguments("--proxy-server='direct://'");
chromeOptions.addArguments("--proxy-bypass-list=*");
WebDriver driver = new ChromeDriver(chromeOptions);
Step 1: Check your browser version with your webdriver version on this page: https://chromedriver.chromium.org/downloads
Step 2: If after followed above step till you have the same issue then follows the below method:
public class TestSelenium {
private static WebDriver driver;
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver","user.dir");
driver = new ChromeDriver();
driver.get("https://www.google.com");
}
}

URL not typing in firefox selenium

Url is not tying in firefox browser. I am using latest version of selenium jar(ver:27) and latest version of firefox(40.0.3).
My code is:
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class first {
public static void main(String args[])
{
WebDriver driver = new FirefoxDriver();
driver.get("http://www.google.com");
}
}
Please udate your jar to latest one. Had similar problem with old java jar and latest firefox
The current version of Selenium is 2.47.1. The current version of Firefox is 41.0. If you get them both updated, it should work.
Selenium download page

Selenium Web Driver firefox not responding

I am using simple selenium example using Web driver classes, but the IE web driver class working fine, but the Firefox is not responding not opening browser and not throwing any error in console.
code is here
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class GoogleSearchFF {
public static void main(String args[]){
WebDriver driver=new FirefoxDriver();
System.out.println("Loading Google search page");
driver.get("http://www.google.com");
System.out.println("Google search page loaded fine");
}
}
selenium jar files added to classpath..
\selenium-java-2.13.0\selenium-2.13.0\selenium-java-2.13.0.jar
\selenium-java-client-driver-1.0.1\selenium-java-client-driver.jar
\Selenium Latest\selenium-server-standalone-2.13.0.jar
any jar is missing?
The code works for IE by setting proeprty INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS = true
Downgrade the Firefox version to 8 as Selenium 2.13.0 supports Firefox versions upto 8 only.
For reference check this log.
Instead of downgrading Firefox to 8,
You need to download the geckodriver.exe and set the System.property() by
System.setProperty("webdriver.gecko.driver", "pathTogeckodriver");
before calling WebDriver driver = new FirefoxDriver();