IDE: Visual Studio 2015
Geckodriver.exe (Version 0.19.0) - Published: 9/25/2017
Firefox version: 56.0b8 (64-bit)
Selenium webdriver version: 3.6.0
Using Selenium and C # I did as lines of code below:
using (FirefoxDriver = new FirefoxDriver () driver)
{
driver.Navigate (). GoToUrl("https://www.teste.gov.br/seguro/loginPortal.asp");
Thread.Sleep (1000 * 60);
}
The page opens a message of "Your connection is not private", error "Your connection is not secure".
To resolve this issue you have already used the following codes:
profile = webdriver.FirefoxProfile ()
profile.accept_untrusted_certs = True
driver = new FirefoxDriver (profile)
profile = webdriver.FirefoxProfile ()
profile.accept_untrusted_certs = True
driver = new FirefoxDriver (profile)
profile.setAcceptUntrustedCertificates (true);
profile.setAssumeUntrustedCertificateIssuer (false);
driver = new FirefoxDriver (profile)
ffProfile.setAcceptUntrustedCertificates (true)
ffProfile.setAssumeUntrustedCertificateIssuer (false)
driver = new FirefoxDriver (ffProfile)
and other codes ...
But the problem continues. How to solve this problem?
TL:DR; There is no reasonable approach to solving this problem.
If it's absolutely necessary to visit the site only, e.g. to create a cookie, use PhantomJS. Every browser driver I've tried gives the error, and it's impossible to bypass without some sort of security exploit.
The browser is literally letting you know the site is insecure. Albeit its a government site, it might be compromised.
On a separate note, its probably cleaner to do this:
FirefoxDriver() ffDriver = new FirefoxDriver();
ffDriver.Navigate("myCoolSite.url");
Related
Most of the answers I found was depricated or useless.
These are what I tried to load available profile instead of instantiate a new one ( I need to use cached files to have fast tests running).
FirefoxOptions firefoxOption = new FirefoxOptions()
{
AcceptInsecureCertificates = true
};
FirefoxProfileManager firefoxProfileManager = new FirefoxProfileManager();
firefoxOption.Profile = firefoxProfileManager.GetProfile("Profile 2");
Result: a new instance of profile 2 is created and not using cached files/bookmarks/cookies of profile 2
firefoxOption.AddArgument(#"-user-data-dir=C:\tempFolder");
firefoxOption.AddArgument(#"-user-data-dir=C:\Users\Ehsan\AppData\Local\Mozilla\Firefox\Profiles\vyt729xj.appointment");
firefoxOption.AddArguments("-profile", #"C:\Users\Ehsan\AppData\Local\Mozilla\Firefox\Profiles\vyt729xj.appointment");
firefoxOption.SetPreference("-profile", #"C:\Users\Ehsan\AppData\Local\Mozilla\Firefox\Profiles\vyt729xj.appointment");
Result: useless effort and still creating a new instance of Default profile and not using previous caching(The page load time is obviously clear that all the files are being get from the net not from cache)
firefoxOption.Profile = new FirefoxProfile(#"C:/Users/Ehsan/AppData/Local/Mozilla/Firefox/Profiles/vyt729xj.appointment");
IWebDriver firefoxDriver = new FirefoxDriver(firefoxOption);
Result: exception :
Failed to set preferences: Unable to read profile preferences file
(SessionNotCreated)
How to force Selenium to use the Firefox profile to get access to previous cookies/settings/caches/bookmarks ? And not making a new instance of Firefox profile? Or at least create a new instance but use old caches/setting/bookmark/cookies?
Extra Info: C# is better but solution in other languages will be a hint.
I did it so easily using chrome and edge like this:
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.AddArguments(#"--user-data-dir=F:\Program Files\Chrome\Profile1");
IWebDriver chromeDriver = new ChromeDriver(chromeOptions);
Update 1: Current trick is to make a new instance but use a fix address for cache:
FirefoxOptions firefoxOption = new FirefoxOptions();
firefoxOption.SetPreference("browser.cache.disk.parent_directory", #"F:\Program Files\Firefox Developer Edition\Cache");
IWebDriver firefoxDriver = new FirefoxDriver(firefoxOption);
I am trying to learn how to write automated web tests in SauceLabs, and Visual Studio is telling me that DesiredCapabilities is deprecated in Selenium 3. I figured out how to use ChromeOptions for desktop tests, but what about mobile web tests? This works:
DesiredCapabilities caps = new DesiredCapabilities();
caps.SetCapability("deviceName", "iPhone 8 Simulator");
caps.SetCapability("deviceOrientation", "portrait");
caps.SetCapability("platformVersion", "12.0");
caps.SetCapability("platformName", "iOS");
caps.SetCapability("browserName", "Safari");
caps.SetCapability("username", SauceUsername);
caps.SetCapability("accessKey", SauceAccessKey);
caps.SetCapability("name", TestContext.TestName);
_driver = new RemoteWebDriver(new Uri("http://ondemand.saucelabs.com:80/wd/hub"),
caps, TimeSpan.FromSeconds(600));
But I don't want to use a deprecated class. I've used Selenium exensively in the past, but this my first time doing mobile web tests (no apps, just Safari/mobile Chrome). Should I be using an Appium Driver instead?
There will be a AppiumOptions() in a future release of Appium v4 that will replace this. You can pull it down now and give it a try.
It will look something like this:
public void SimpleTest()
{
var appiumOptions = new AppiumOptions();
appiumOptions.AddAdditionalCapability(MobileCapabilityType.PlatformName, "Android");
appiumOptions.AddAdditionalCapability(MobileCapabilityType.PlatformVersion, "7.1.1");
appiumOptions.AddAdditionalCapability(MobileCapabilityType.FullReset, true);
appiumOptions.AddAdditionalCapability(MobileCapabilityType.NewCommandTimeout, 60);
appiumOptions.AddAdditionalCapability("testobject_api_key", "0D6C044F19D0442BA1E11C3FF087F6A6");
appiumOptions.AddAdditionalCapability("username", SauceUser.Name);
appiumOptions.AddAdditionalCapability("accessKey", SauceUser.AccessKey);
//TODO first you must upload an app to Test Object so that you get your app key
var rdcUrl = "https://us1.appium.testobject.com/wd/hub";
var driver = new AndroidDriver<IWebElement>(new Uri(rdcUrl), appiumOptions);
driver.Navigate().GoToUrl("https://www.ultimateqa.com");
Console.WriteLine("");
driver.Quit();
}
I think you should try this with appium driver. Just download appium c# client and start. You can use following link to start with.
http://appium.io/docs/en/writing-running-appium/web/mobile-web/
I'm not able to launch IE browser to run my selenium automated tests written in C#.
I know the problem is that I don't have the security settings set to the same level.
I also know that the way to fix this normally is to simply select the same security level for all zones in IE security tab. BUT My work has made the security tab unavailable to me. Does anybody know another work around for this issue?
//Start Opening browser
DesiredCapabilities caps = DesiredCapabilities.InternetExplorer();
caps.SetCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
driver = new InternetExplorerDriver(caps);
driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
driver.Manage().Window.Maximize();
driver.Navigate().GoToUrl(this.baseURL);
Thank you in advance!
Found a solution. In addition to ignoring protected mode settings I also ignore zoom settings and clicks were not working so I also ignore native events.
Here is the new code:
var options = new InternetExplorerOptions()
{
InitialBrowserUrl = baseURL,
IntroduceInstabilityByIgnoringProtectedModeSettings = true,
IgnoreZoomLevel = true,
EnableNativeEvents = false
};
driver = new InternetExplorerDriver(options);
driver.Manage().Window.Maximize();
driver.Navigate().GoToUrl(this.baseURL);
Yes, you can do it using DesiredCapabilities class of selenium WebDriver
// Set capability of IE driver to Ignore all zones browser protected mode settings.
DesiredCapabilities caps = DesiredCapabilities.internetExplorer();
caps.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,true);
// Initialize InternetExplorerDriver Instance using new capability.
WebDriver driver = new InternetExplorerDriver(caps);
driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
Hope the same code works for you.
I've managed to handle a missing security certificate in IE8, however quite often the browser will hang while loading "Downloading picture res://ieframe.dll/background_gradient_red.jpg..." and any following IE tests on the node fail also.
I'm working with the ops team to fix the certificate issue, but in the meantime has anyone else seen this problem?
In case it helps here is how I'm creating the driver...
DesiredCapabilities capabilities = DesiredCapabilities.InternetExplorer();
capabilities.SetCapability(CapabilityType.AcceptSslCertificates, true);
capabilities.SetCapability(CapabilityType.HandlesAlerts,true);
capabilities.SetCapability("ignoreProtectedModeSettings",true);
driver = new RemoteWebDriver(new Uri(GridHubUrl), capabilities);
driver.Manage().Cookies.DeleteAllCookies();
driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(60));
driver.Manage().Timeouts().SetScriptTimeout(TimeSpan.FromSeconds(60));
And this bit handles clicking override...
public static void Handle()
{
if (driver.ToString() == "OpenQA.Selenium.IE.InternetExplorerDriver" ||
driver.Url.Contains("res://ieframe.dll/invalidcert.htm"))
{
try
{
driver.Navigate().GoToUrl("javascript:document.getElementById('overridelink').click()");
Today I faced the same issue, but resolved by doing this-
Browser setting:
In your browser go to:
Settings-> Internet Options->Security-> Trusted Sites ->"Sites" button -> Add your site
System.setProperty("webdriver.ie.driver","C:\\Users\\XXXXXX\\Desktop\\selenium jars\\Eclipse Jars\\IEDriverServer_x64_2.29.0\\IEDriverServer.exe");
DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer();
capabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,true);
driver = new InternetExplorerDriver();
driver.get(baseUrl + "/content/");
driver.navigate().to("javascript:document.getElementById('overridelink').click()");
driver.findElement(By.id("edit-acct")).clear();
I'm using Selenium RC + .Net Client Driver. I've created a Firefox profile in my c:\selenium\ directory. Here's my code:
Dim MySelenium As ISelenium = Nothing
MySelenium = New DefaultSelenium("localhost", 4444, "*custom C:/Program Files/Mozilla Firefox/firefox.exe -profile c:/selenium/", "http://www.google.com/")
When I run this, I get the following error:
Failed to start new browser session: Error while launching browser
What is the proper way to do this?
You need to launch it via RC rather than in your code.
So you would do
java -jar selenium-server.jar -firefoxProfileTemplate c:\selenium\
to launch the browser and then do
Dim MySelenium As ISelenium = Nothing
MySelenium = New DefaultSelenium("localhost", 4444, "*firefox", "http://www.google.com/")
and that should launch Firefox for with the profile you want.
In Java you can create the Selenium Server programmatically and pass a File as the newFirefoxProfileTemplate configuration property:
RemoteControlConfiguration rcc = new RemoteControlConfiguration();
rcc.setPort(5499);
rcc.setFirefoxProfileTemplate(newFirefoxProfileTemplate); // This is a File object
SeleniumServer server = new SeleniumServer(rcc);
server.start();
Perhaps there are similar (or the same) vb.net classes available.