Selenium Secure Socket Layer Issue in Selenium 3 - selenium-webdriver

How could I handle ssl certifiaction error in selenium 3 and above for firefox 49+.
It will be helpful if anyone could answer. Thanks in advance

For chrome :
DesiredCapabilities SSLErr = DesiredCapabilities.chrome ()
SSLErr.setCapability (CapabilityType.ACCEPT_SSL_CERTS, true)
WebDriver driver = new ChromeDriver (lSSLErr);
or
ChromeOptions option= new ChromeOptions();
option.addArguments("headless");
option.addArguments("ignore-certificate-errors");
WebDriver d=new ChromeDriver(option);
For Firefox
FirefoxProfile profileSSL = new FirefoxProfile();
profileSSL.setAcceptUntrustedCertificates(true);
profileSSL.setAssumeUntrustedCertificateIssuer(false);
driver = new FirefoxDriver(profileSSL)

Hi Actually none of the above worked for me, I am using Selenium 2.35.1 and Firefox 49. So I used try catch method, where I am catching that WebDriverException and clicking on exception using selenium and AutoIT to close the window based popup

Related

Can't open Private window in Edge Browser using Selenium

I have tried below mentioned code, but its not working in my framework.
Selenium -3.141.59
Microsoft Edge- 81.0.416.72
EdgeOptions options = new EdgeOptions();
options.setCapability("inPrivate", true);
WebDriver driver = new EdgeDriver(options);
You could try to add argument inprivate to make Edge Chromium open in Private mode using Selenium WebDriver.
Please refer to the following steps:
Download the language binding of Selenium 4.00-alpha05 from here.
Download the matching version of Microsoft Edge Driver from this page.
Then, using the following code (it works well in C# and Java application):
EdgeOptions edgeOptions = new EdgeOptions();
edgeOptions.addArguments("-inprivate");
WebDriver driver = new EdgeDriver(edgeOptions);

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

Remote WebDriver UnreachableBrowserException: Could not start a new session

I got this exception for all browsers. For example, I create a remote webdriver on chrome like this:
caps = DesiredCapabilities.chrome();
ChromeOptions options = new ChromeOptions();
options.addArguments("disable-infobars");
caps.setCapability(ChromeOptions.CAPABILITY, options);
webDriver = new RemoteWebDriver(new URL("http://myIP:5555/wd/hub"), caps);
And I got UnreachableBrowserException as follow:
org.openqa.selenium.remote.DesiredCapabilities chrome
INFO: Using `new ChromeOptions()` is preferred to `DesiredCapabilities.chrome()`
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.
But I check my selenium hub at http://myIP:4444/grid/console, everything is fine, the node is stil registered. I then check my node at http://myIP:5555/wd/hub/static/resource/hub.html, I still can click "Create Session" to create a session for all browsers.
I just got this exception today, it still worked few days ago. I am using Selenium 3.11.0, IntelliJ 2017.3, all drivers and browsers are latest versions.
I googled here, but I can't find a solution for this while my gird is still running. Any help much appreciated.
The error says it all :
INFO: Using `new ChromeOptions()` is preferred to `DesiredCapabilities.chrome()`
The current implementation of Selenium while invoking RemoteWebDriver supports the ChromeOptions and you can use the following code block :
ChromeOptions options = new ChromeOptions();
options.addArguments("disable-infobars");
webDriver = new RemoteWebDriver(new URL("http://myIP:5555/wd/hub"), options);
Update
As per your comment update the documentation at seleniumhq-documentation is yet to be updated. Here are the relevant bytes from the Selenium Release Notes :
Selenium v3.5.0 :
* Start making *Option classes instances of Capabilities. This allows
the user to do:
`WebDriver driver = new RemoteWebDriver(new InternetExplorerOptions());`
Selenium v3.6.0 :
* All `*Option` classes now extend `MutableCapbilities`
`new RemoteWebDriver(new ChromeOptions());`
Selenium v3.7.0 :
* Migrated from using `DesiredCapabilities` to either
`MutableCapabilities` or (preferably) `ImmutableCapabilities`.

How to use OperaChromiumDriver for opera version >12.X

I understand that to work on opera versions > 12.X, Operachromiumdriver has been developed. At the same time I couldn't get this to work. I downloaded the windows version of operachromiumdriver.exe from https://github.com/operasoftware/operachromiumdriver/releases but to no avail. Can someone help me with this . Please tell me if my understanding is right.
Thanks
I have found the solution running opera 25+ using OperaChromiumDriver.exe.
Install Opera 25+ (I installed Opera 25)
Download OperaChromiumDriver https://github.com/operasoftware/operachromiumdriver/releases
Extract the zip file to a location on the computer
Use the following code to open Opera
System.setProperty("webdriver.chrome.driver", "C:/Users/user/Downloads/operadriver-0.1.0-win32/operadriver-0.1.0-win32.exe");
WebDriver driver = new ChromeDriver();
driver.get("https://www.google.com");
driver.findElement(By.name("q")).sendKeys("Selenium");
I have used new ChromeDriver(). This will start Opera since we are using OperaChromiumDriver. I think this is because the new Opera is based on Chromium and OperaChromiumDriver is a WebDriver implementation derived from ChromeDriver [See https://github.com/operasoftware/operachromiumdriver].
Hope this helps you.
OperaChromiumDriver now works with Opera 26+ but only with a remote instance so far... Download and launch the appropriate binary from
OperaChromiumDriver Binary Releases
They have examples for Desktop versions in python but here's what worked for me in Java. Many ChromeOptions do not work though it says they should... you will have to test to know for sure but the setBinary does work.
DesiredCapabilities capabilities = DesiredCapabilities.opera();
ChromeOptions options = new ChromeOptions();
options.setBinary("/path/to/opera");
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
driver = new RemoteWebDriver(new URL("http://127.0.0.1:9515"),capabilities);
Operachromiumdriver
Download selenium Drivers. As their is no direct opera driver, OperaChromiumDriver is based on ChromeDriver, so we are Using ChromeOptions to set binary location of operadriver.exe
Chromium-based versions of Opera starting from version 26.
String operaChromiumDriver = "E:\\Drivers\\operadriver.exe";
String operaBrowserLocation = "C:\\......\\opera.exe"
System.setProperty("webdriver.opera.driver", operaChromiumDriver);
ChromeOptions options = new ChromeOptions();
options.setBinary(operaBrowserLocation);
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
OperaDriver browser = new OperaDriver(capabilities);
WebDriver driver =browser;
driver.get("https://in.yahoo.com/");
thanks to Lukus Answer(1) to complete my work.

Issue while handling proxy prompts with the Firefox driver

I am facing issue with the proxy prompts for firefox browser with version 17.
I tried the steps mentioned in this link. But still am getting the prompts.
Also referred selenium document for using proxies, but unable to succeed.
I need to use FF17 only as per my project req and am using selenium 2.28.
My company proxy addr is proxy.comp_name.com port: 8080.
I am not getting any proxy prompts while doing manually.
While running multiple tests prompt will be displayed arbitrarily.
Any updates on the below issue?
code used to launch the driver with the default firefox profile
FirefoxProfile profile = new ProfilesIni().getProfile("default");
DesiredCapabilities dCap = DesiredCapabilities.firefox();
dCap.setCapability(FirefoxDriver.PROFILE, profile);
driver = new FirefoxDriver(dCap);
code used to launch the driver with the new profile:
String PROXY = "proxy.abc.com:8080";
org.openqa.selenium.Proxy proxy = new org.openqa.selenium.Proxy();
proxy.setHttpProxy(PROXY)
.setFtpProxy(PROXY)
.setSslProxy(PROXY);
DesiredCapabilities cap = new DesiredCapabailities();
cap.setCapability(CapabilityType.PROXY, proxy);
WebDriver driver = new FirefoxDriver(cap);
Also I tried by setting Preferences to the firefox profile, but still am getting the proxy prompts..
FirefoxProfile firefoxProfile = new FirefoxProfile();
firefoxProfile.setPreference("network.proxy.type", ProxyType.SYSTEM.ordinal());
firefoxProfile.setPreference("signon.autologin.proxy" , true );
firefoxProfile.setEnableNativeEvents(false);
desiredCapabilities.setCapability(FirefoxDriver.PROFILE, firefoxProfile);
return new FirefoxDriver(desiredCapabilities);
Proxy proxy = new Proxy();
proxy.setProxyAutoconfigUrl("");
// We use firefox as an example here.
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability(CapabilityType.PROXY, proxy);
// You could use any webdriver implementation here
WebDriver driver = new FirefoxDriver(capabilities);

Resources