Insecure connection error in Firefox using Selenium webdriver using java - selenium-webdriver

FF: 52.6 ESR version
Selenium : 3.5.2
Gecko driver : v0.15
FirefoxProfile profile = new FirefoxProfile();
System.setProperty("webdriver.gecko.driver", "D:/geckodrivers/geckodriver-v0.15.0-win64/geckodriver.exe");
profile.setAcceptUntrustedCertificates(true);
profile.setAssumeUntrustedCertificateIssuer(true);
driver = new FirefoxDriver(profile);
I am using this code and still getting insecure connection error. If I use capabilities, the url itself is not opening in FF browser. Issue not replicating in Chrome and IE.

Related

This site can't be reached error while trying to run selenium WebDriver script with selenium docker chrome node

I am trying to run selenium tests on docker with selenium docker chrome node. We are running this on windows 7. Since docker does not support windows 7, we are using vagrant to create linux box and then run selenium hub and selenium node/chrome using docker on the linux box.
When I try to run selenium script using below code, I get "This site can't be reached" error. However chrome session gets created successfully and driver launches the website. But the site displays error as "This site can't be reached"
ChromeOptions options = new ChromeOptions();
WebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), options);
driver.manage().timeouts().implicitlyWait(90, TimeUnit.SECONDS);
driver.get("http://www.google.com");
My company is using proxy server. I have set the proxy settings in vagrant vm box and docker containers also. So when I use "curl www.google.com" on linux box and docker selenium containers,I get the response back successfully.
When I can launch the website successfully on containers and linux box, I am not sure why website is not rendered when launched through selenium WebDriver.
I have tried launching the WebDriver with proxy settings as below but same error is present
Proxy proxy = new Proxy();
proxy.setProxyType(Proxy.ProxyType.MANUAL)
proxy.setHttpProxy("<username>:<password>:<proxy_url>)
ChromeOptions options = new ChromeOptions();
options.setCapability("proxy", proxy);
WebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), options);
driver.manage().timeouts().implicitlyWait(90, TimeUnit.SECONDS);
driver.get("http://www.google.com");

Authentication pop up chrome browser

How to handle authentication pop up in chrome browser by using selenium web driver?
Try:
WebDriver driver = new ChromeDriver(options)
driver.get("http://username:password#www.domain.com");
or
ChromeOptions options = new ChromeOptions();
options.addArguments("user-data-dir=/path/to/your/custom/profile");
WebDriver driver = new ChromeDriver(options);
driver.navigate().to(testURL);
References:
https://sites.google.com/a/chromium.org/chromedriver/capabilities
https://chromium.googlesource.com/chromium/src/+/master/docs/user_data_dir.md

Get error org.openqa.selenium.firefox.NotConnectedException when running the selenium code

getting the below error
org.openqa.selenium.firefox.NotConnectedException
Firefox : 32.0
Eclipse : Version: Neon.1a Release (4.6.1)
Upgrade your firefox You need to install geckodriver from this link:
Gecko driver download from here
and then set the setProperty()
System.setProperty("webdriver.gecko.driver", "E:\\software and tools\\geckodriver.exe");
WebDriver driver = new FirefoxDriver();
driver.get("http://www.google.com");
If you are using selenium jar 2.53 and browser firefox 45.0, then no need to set gecko driver:
WebDriver driver = new FirefoxDriver();
driver.get("http://www.google.com");

Not able to automate Opera browser through Selenium WebDriver

I'm automating a web application which runs in 3 browsers, IE, Mozilla and Chrome.
Now when I try to run the same code in Opera with different capabilities, it opens Opera browser but in URL only data; is displayed and my tests are not running.
Here is my sample code:
DesiredCapabilities capabilities = DesiredCapabilities.operaBlink();
System.setProperty("webdriver.opera.driver", "C:\\Important\\Test\\web\\src\\test\\resources\\operadriver.exe");
driver = new OperaDriver(capabilities);
driver.manage().window().maximize();
I'm getting following error:
org.openqa.selenium.WebDriverException: Opera not reachable (Driver info: OperaDriver=0.2.0 (ba47709ed9e35ce26dbd960fb5d75be104290d96),platform=Windows NT 6.1 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)
I tried this with Windows 10, Selenium 3.5.2, Opera 52.0 and OperaDriver 2.35 and the following code works for me.
DesiredCapabilities capablities=DesiredCapabilities.opera();
System.setProperty("webdriver.opera.driver", "C:\\automation\\opera\\operadriver.exe");
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.setBinary("C:\\Program Files\\Opera\\launcher.exe");
capablities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);
OperaDriver driver = new OperaDriver(capablities);
driver.get("https://www.google.com");
driver.findElement(By.name("q")).sendKeys("how to use opera with selenium");
Please Try with
DesiredCapabilities capabilities = DesiredCapabilities.opera();

Selenium Webdriver + Java - How to configure automatic proxy configuration URL for firefox?

I'm trying to configure my FirefoxDriver to use automatic proxy configuration URL. I am failing to do so.
My code looks like this:
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("network.proxy.type", 2);
profile.setPreference("network.proxy.autoconfig_url", "http://10.203.193.52/Proxy-cmv.pac");
WebDriver driver = new FirefoxDriver();
I am not receiving any kind of errors but the connection is not working for this browser. When checking Options > Advanced > Network > Connection Settings from Firefox menu, proxy is set to "Use system proxy".
You need to use that profile, because now you just create it.
So, change:
WebDriver driver = new FirefoxDriver();
to
WebDriver driver = new FirefoxDriver(profile);

Resources