Chromebrowser show "data:," instead of the parameter passed in selenium - 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/");
}
}

Related

How to execute selenium scripts on an already opened browser

The code below open a new blank window
any solution?
tanks!
Chrome Version 90.0.4430.72 (Official Build) (32-bit)
ChromeDriver 90.0.4430.24
and tried with version
Chrome version 100.0.4896.127
\command line code:
C:\Program Files (x86)\Google\Chrome\Application>chrome.exe --remote-debugging-port=9222 -user-data-dir="D:\Programing\Programing App\chromedriver_win32\chromedata"
\ java code:
package selenium1;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
public class Chromeoptiontest {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver",
"D:\\Programing\\Programing App\\oldChromeDriver\\chromedriver.exe");
ChromeOptions option = new ChromeOptions();
option.setExperimentalOption("debuggerAddress", "127.0.0.1:9222");
ChromeDriver driver = new ChromeDriver(option);
}
}
It's officially not supported.
However, there is some working code which claims to support this:
https://web.archive.org/web/20171214043703/http://tarunlalwani.com/post/reusing-existing-browser-session-selenium-java/.

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.

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");
}
}

Type mismatch: cannot convert from FireFoxDriver to WebDriver

enter image description here
package demo;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class FacebookRegistration {
public static void main(String[] args) {
WebDriver driver = new FireFoxDriver();
driver.get("http://www.facebook.com");
}
}
Have you seen the typo in your IDE? You've imported FirefoxDriver and try to instantiate FireFoxDriver
You have exactly 2 problems in your code as follows :
import :
As you have used import org.openqa.selenium.firefox.FirefoxDriver; on similar lines you have to use :
WebDriver driver = new FirefoxDriver();
System.setProperty() :
While you work with Selenium v3.x.x you have to download the latest geckodriver binary from this link, save it in your system and provide the absolute path of the geckodriver binary through System.setProperty() line as follows :
System.setProperty("webdriver.gecko.driver", "C:\\path\\to\\geckodriver.exe");

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

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");
}
}