firefox marionette bypass security exception - selenium

I am using Marionette / Geckodriver v9.0 for mac with selenium jar 2.53.1.
When it opens firefox 47 I'm getting the error that "Your connection is not secure".
The code I'm using to create the driver is:
FirefoxProfile firefoxProfile = null;
firefoxProfile = new FirefoxProfile();
firefoxProfile.setAcceptUntrustedCertificates(true);
firefoxProfile.setAssumeUntrustedCertificateIssuer(false);
DesiredCapabilities capability = DesiredCapabilities.firefox();
capability.setCapability("marionette", true);
capability.setCapability(FirefoxDriver.PROFILE, firefoxProfile);
capability.setCapability("handlesAlerts", true);
return new MarionetteDriver(capability);
So, how do I get it to add my website as an exception or turn off the check? Or is it a feature that Marionette hasn't implemented yet?

Firefox: 50.1.0
Gecko Driver: 0.13 (install nuget package: Selenium.Firefox.WebDriver.0.13.0)
Firstly, open a standard Firefox browser, and make sure the default Firefox profile has added the unsecured site into the certificate exception list.
C# code as follows:
FirefoxProfileManager fpManager = new FirefoxProfileManager();
var profiles = fpManager.ExistingProfiles;
var defaultProfile = fpManager.GetProfile(profiles.First());
driver = new FirefoxDriver(defaultProfile);

You have to use nightly build of firefox of developer edition for now. It will not work on the current version.
https://bugzilla.mozilla.org/show_bug.cgi?id=1103196

Related

Does not direct to page in Microsoft Edge due to selenium.WebDriverException: Unable to parse remote response: Unknown error

I initiated web driver and try to connect a URL and it returns an exception
What happens is: Open the web browser but does not direct to given Url and print error on the console log.
My code is below:
Webdriver driver = new EdgeDriver();
driver.get("https://learn.microsoft.com/en-us/welcome-to-docs");
Error log:
org.openqa.selenium.WebDriverException: Unable to parse remote response: Unknown error
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:115)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:74)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:136)
I enabled developer mode
I already installed WebDriver using below command in (C:\WINDOWS\system32>):
DISM.exe /Online /Add-Capability /CapabilityName:Microsoft.WebDriver~~~~0.0.1.0
I use the below versions:
selenium version: '3.141.59'
Browser: Microsoft Edge, Version 80.0.361.50 (Official Build)
(64-bit)
os build: 18362.535
Windows Edition: 10 version 1903
Any Idea on this?
DISM.exe /Online /Add-Capability
/CapabilityName:Microsoft.WebDriver~~~~0.0.1.0
Using the above command will install the Microsoft WebDriver for Microsoft Edge Legacy versions 18, it is not available for the Microsoft Edge Version 80.0.361.50 (Official Build) (64-bit).
You could download the related Microsoft Edge WebDriver from Here, based on the Edge version number to download the WebDriver.
Edit:
Try to use the EdgeOptions to set the webdriver path, code as below:
using OpenQA.Selenium.Edge;
using OpenQA.Selenium.Remote;
// EdgeOptions() requires using OpenQA.Selenium.Edge
// Construct EdgeOptions with is_legacy = false
EdgeOptions edgeOptions = new EdgeOptions(false);
edgeOptions.BinaryLocation = #"C:\Program Files (x86)\Microsoft\Edge Beta\Application\msedge.exe";
var msedgedriverDir = #"<download webdriver folder such as:D:\MicrosoftEdgeDriver\edgedriver_win64>";
var msedgedriverExe = #"msedgedriver.exe";
// Construct EdgeDriverService with is_legacy = false too
var service = EdgeDriverService.CreateDefaultService(msedgedriverDir, msedgedriverExe, false);
service.EnableVerboseLogging = true;
var driver = new EdgeDriver(service, edgeOptions);
driver.Navigate().GoToUrl("https://bing.com");
Thread.Sleep(2000);
driver.Close();
More detail information about using Chromium version Edge WebDriver, please check this link:
WebDriver (Chromium)

unknown error: cannot focus element using ChromeDriver Chrome and Selenium through VB Net

I face the error cannot focus element. it looks like
i have no idea for fix it, this is what I was did, can anyone help me to fix it?
Try
Dim options As ChromeOptions = FrmWABot.options
options = New ChromeOptions
options.AddArguments("user-data-dir=" & Application.StartupPath & "/profile")
Clipboard.SetText(no)
Dim element As IWebElement = driver.FindElement(By.XPath("//*[#title='Search or start new chat']"))
Clipboard.SetText(no)
With element
.SendKeys(Keys.Control + "v")
.SendKeys(Keys.Enter)
End With
Dim elpesan As IWebElement = driver.FindElement(By.XPath("//*[#id='main']/footer/div[1]/div[2]/div/div[2]"))
With elpesan
Clipboard.SetImage(getImage())
.SendKeys(Keys.Control + "v")
.SendKeys(Keys.Enter)
End With
Dim element1 As IWebElement = driver.FindElement(By.XPath("//*[#id='app']/div[1]/div[1]/div[2]/div[2]/span/div[1]/span/div[1]/div[1]/div[2]/div[1]/span/div[1]/div[2]/div[1]/div[3]/div[2]"))
element1.Click()
With element1
Clipboard.SetText("Happy Birthday...")
.SendKeys(Keys.Control + "v")
.SendKeys(Keys.Enter)
End With
Catch ex As Exception
ex.ToString()
End Try
This error message...
unknown error: cannot focus element (Session info: chrome=77.0.3865.90) (Driver info: chromedriver=2.38.552522
...implies that the ChromeDriver was unable to focus on the WebBrowser i.e. Chrome Browser session.
Your main issue is the incompatibility between the version of the binaries you are using as follows:
You are using chromedriver=2.38
Release Notes of chromedriver=2.38 clearly mentions the following :
Supports Chrome v65-67
Presumably you are using chrome= 77.0
Release Notes of ChromeDriver v77.0 clearly mentions the following :
Supports Chrome version 77
So there is a clear mismatch between the ChromeDriver v2.38 and the Chrome Browser v77.0
Solution
Ensure that:
ChromeDriver is updated to current ChromeDriver v77.0 level.
Chrome is updated to current Chrome Version 77.0 level. (as per ChromeDriver v77.0 release notes)
Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
If your base Web Client version is too old, then uninstall it and install a recent GA and released version of Web Client.
Take a System Reboot.
You can find a relevant discussion in “Message=unknown error: cannot focus element” while executing tests through Selenium, ChromeDriver and Chrome
Try to use action class instead of regular script
Actions action = new Actions(driver);
action.MoveToElement(element).Build().Perform();

Unable to find a matching set of capabilities with selenium 3.8.1 and gecko driver 0.19.0

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
//import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class Webdriver {
public static void main(String[] args) throws InterruptedException {
// TODO Auto-generated method stub
System.setProperty("webdriver.gecko.driver", "C:\\Selenium\\geckodriver.exe");
WebDriver driver = new FirefoxDriver();
//System.setProperty("webdriver.chrome.driver","C:\\Selenium\\chromedriver.exe");
//WebDriver driver = new ChromeDriver();
driver.get("https://maps.mapmyindia.com");
Thread.sleep(2000);
driver.findElement(By.id("auto")).sendKeys("TCS");
Thread.sleep(2000);
driver.findElement(By.id("auto_geo")).click();
When i run this code on eclipse luna there is an error: Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Unable to find a matching set of capabilities
new FirefoxDriver(DesiredCapabilities caps);
is deprecated, use
FirefoxOptions options = new FirefoxOptions();
options.setCapability("marionette", false);
WebDriver webDriver = new FirefoxDriver(options);
and you are good to go
Another possible cause is the outdated Firefox version.
I upgraded the version and it works fine!
I could open the browser only setting options.setCapability("marionette", true);, then in the open window I upgraded through the "About Firefox" dialog. Then you have to remove the line about marionette.
Probably the one I had was only going to work with marionette while we are trying to use it with geckodriver, which has a different protocol. Anyone who knows more than me can confirm or deny!
SessionNotCreatedException
SessionNotCreatedException extends WebDriverException and is a RuntimeException which indicates that a session could not be created.
Possible Causes :
The possible causes of a new session not getting created are as follows :
Compatibility issues between JDK, Selenium, WebDriver and Web Browser versions.
Accessing the same port number by GeckoDriver or Marionette by the new session which previous session have't released yet.
Lack of access to CPU
Lack of Physical Memory
Lack of Swap Memory
Lack of Disc Cache
Lack of Network Bandwidth
Presence of OS chores within the system.
Code Block :
I don't see any coding issue in your code block as such.
Solution :
The simple solution would be as follows :
Always use the latest released version of JDK (Java SE 9.0.1), Selenium-Java client (v3.8.1), WebDriver variant (GeckoDriver v0.19.1) and Web Browser (Firefox Quantum Browser).
If the base version of the Web Browser is too old consider uninstalling the Browser through Revo Uninstaller and install a recent released GA version of Firefox Browser.
Always use quit() in the tearDown() method so that the webdriver and the webclient both are properly destroyed.
Clean the Project Workspace from your IDE before and after executing your Test Suite.
Clear the Browser Cache before and after the execution of your Tests.
Use CCleaner tool regularly to wipe away the OS chores.
Execute your Test.
You should add capabilities for firefox. Please modify your code as follows
System.setProperty("webdriver.gecko.driver", "C:\\Selenium\\geckodriver.exe");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities = DesiredCapabilities.firefox();
capabilities.setBrowserName("firefox");
capabilities.setVersion("your firefox version");
capabilities.setPlatform(Platform.WINDOWS);
capabilities.setCapability("marionette", false);
WebDriver driver = new FirefoxDriver(capabilities);
driver.get("https://maps.mapmyindia.com");
If your windows is windows_nt then put windows_nt instead of windows

Unable to start operaBlink through selenium webdriver

I am trying to start opera(v 36.0) using selenium 2.53.0 and Opera chromium driver _win64 (0.2.2).
When I try to run sample code, an exception occurred and browser didn't started.
Sample code:
File pathToOpera = new File("E://operadriver.exe");
DesiredCapabilities cap = DesiredCapabilities.operaBlink();
cap.setCapability("webdriver.opera.driver",pathToOpera);
driver = new OperaDriver(cap);
I am getting error as
java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.opera.driver system property; for more information, see https://github.com/operasoftware/operachromiumdriver. The latest version can be downloaded from https://github.com/operasoftware/operachromiumdriver/releases
at com.google.common.base.Preconditions.checkState(Preconditions.java:199)
at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:109)
at org.openqa.selenium.opera.OperaDriverService.access$0(OperaDriverService.java:1)
at org.openqa.selenium.opera.OperaDriverService$Builder.findDefaultExecutable(OperaDriverService.java:118)
at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:296)
at org.openqa.selenium.opera.OperaDriverService.createDefaultService(OperaDriverService.java:82)
at org.openqa.selenium.opera.OperaDriver.<init>(OperaDriver.java:137)
My execution environment: win 8, 64 bit
Add before Your code:
System.setProperty("webdriver.opera.driver","E://operadriver.exe");
System.setProperty("opera.binary","E://yourOperaPath.exe");

NullPointer Exception In running testCases via Selenium webDriver in Chrome

I am trying to run my test cases on Chrome and I had copied the path in the Properties file,but still console is throwing annoying statements like:
ERROR: The path to the chromedriver executable must be set by the webdriver.chrome.driver system property; for more information, see http://code.google.com/p/selenium/wiki/ChromeDriver. The latest version can be downloaded from http://code.google.com/p/chromium/downloads/list
FAILED CONFIGURATION: #BeforeTest startWebSession
java.lang.NullPointerException
One thing I have found is that the Chrome driver cannot be started from within Eclipse. It must be run from a command prompt. At least on Windows 7 64-bit.
Trying to run it from within Eclipse produces this exception:
Exception in thread "main" java.lang.IllegalStateException: The webdriver.chrome.driver system property defined chromedriver executable does not exist: C:\Windows\System32\chromedriver.exe
This problem only occurs for Chrome. IE and FireFox work fine from within Eclipse.
Download the chrome driver from http://code.google.com/p/chromedriver/downloads/list
Initialize your driver object in the following manner -
System.setProperty("webdriver.chrome.driver","C:\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
By doing this the chrome driver works properly.
This is how do I initialize the ChromeDriver:
public RegulationUI() throws Exception{
ChromeDriverService service = ChromeDriverService.createDefaultService();
File file = new File(RegulationUI.class.getResource("/chromedriver.exe").toURI());
System.setProperty(ChromeDriverService.CHROME_DRIVER_EXE_PROPERTY, file.getAbsolutePath());
ChromeOptions options = new ChromeOptions();
options.addArguments("--start-maximized");
driver = new ChromeDriver(service,options);
}
BTW my test class is named RegulationUI
Try this, it works for me and moreover, I know that this is "multicomputer" solution - our project is in subversion and this way everybody can run it, even if we have differently setup where exactly on disk the "working folder" for IDE is
Please download chromedriver.exe for Google chrome browser
please download IEdriver.exe for Internet explore.
Please And kept these files in a root folder of windows for simplicity. Lets consider your operating systems installed on c:\ (C Driver) create a folder name Selenium on C-Drive and Kept these binary(.exe) files. like c:\selenium
in your Testcase/testScript Write as
//For Chrome Browser:
Webdriver driver = new ChromeDriver();
java.io.File file = new File("c:\\selenium\\chromedriver.exe");
System.setProperty("webdriver.chrome.driver", file.getAbsolutePath());
If you are using maven then try to use following in your pom:
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>RELEASE</version>
</dependency>
and use it like this for chrome in your setup:
ChromeDriverManager.getInstance().setup();
driver = new ChromeDriver();