RemoteWebDriver & IE8 hangs Downloading picture res://ieframe.dll/background_gradient_red.jpg - c#

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();

Related

Why wont chromedriver even start on windows 10 server?

currently I have a program that automates task filling.
I intend to run this program on my windows server I connect to via RDP however every time I run the program, selenium chromedriver seems to just go into an idle state and does nothing!
I have the latest chromedriver as of posting.
I've already tried a try-catch and display the errors however none seem to appear
My code for starting chromedriver:
ChromeOptions options = new ChromeOptions();
var driverService = ChromeDriverService.CreateDefaultService();
driverService.HideCommandPromptWindow = true;
options.AddArgument("--window-size=1920,1080");
options.AddArgument("--disable-gpu");
options.AddArgument("--disable-extensions");
options.AddArgument("--log-level=3");
//options.AddArgument("--headless");
options.AddArgument("--disable-notifications");
options.AddArgument("--disable-popup-blocking");
options.AddArgument("ignore-certificate-errors");
options.AddArgument("--proxy-bypass-list=*");
After setting the useragent and proxy I then try to navigate to the link:
//try timeout
try
{
chromedriver.Navigate().GoToUrl(links[rnd.Next(0, links.Length)]);
}
catch (OpenQA.Selenium.WebDriverTimeoutException e)
{
chromedriver.Quit();
Console.WriteLine("[#] Proxy Timeout - Thread Restarting...", Color.Orange);
errors++;
loopt += 10;
continue;
}
Note this program works 100% fine on normal pc's (I've tried 4)
Please help! Thanks in advance

Unsecurity conection - Firefox - Selenium C#

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

Not able to launch IE browser using Selenium webdriver with c#

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.

Edge Browser WebDriver Failure

Attempting to make the code from http://blogs.windows.com/msedgedev/2015/07/23/bringing-automated-testing-to-microsoft-edge-through-webdriver/ work.
Getting an ugly exception.
Repro steps.
Install web driver from links provided ( July 24 2015 WebDriver )
Create console app.
Nuget in Selenium.WebDriver, Selenium.Support.
Run code, console window comes up fine.
When code hits the driver.Url="https://www.bing.com" it throws an exception, as noted below.
NoSuchWindowException - An unhandled exception of type 'OpenQA.Selenium.NoSuchWindowException' occurred in WebDriver.dll
My snippet is below:
using System.IO;
using OpenQA.Selenium;
using OpenQA.Selenium.Edge;
using OpenQA.Selenium.Remote;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Support.UI;
namespace WebDriverPlay
{
public class msedgedev_sample
{
public static void RunMSEdgeDevSample()
{
Console.WriteLine("running MSEdgeDev Sample");
RemoteWebDriver driver = null;
string serverPath = "Microsoft Web Driver";
try
{
if (System.Environment.Is64BitOperatingSystem)
{
serverPath = Path.Combine(System.Environment.ExpandEnvironmentVariables("%ProgramFiles(x86)%"), serverPath);
}
else
{
serverPath = Path.Combine(System.Environment.ExpandEnvironmentVariables("%ProgramFiles%"), serverPath);
}
// location for MicrosoftWebDriver.exe
EdgeOptions options = new EdgeOptions();
options.PageLoadStrategy = EdgePageLoadStrategy.Eager;
driver = new EdgeDriver(serverPath, options);
//Set page load timeout to 5 seconds
driver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(5));
//string _url = #"https://www.bing.com/";
string _url = #"http://www.google.com";
Console.WriteLine("_url=" + _url);
driver.Url = _url;
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
finally
{
if (driver != null)
{
driver.Close();
}
}
}
}
}
After the line:
driver = new EdgeDriver(serverPath, options);
executes, you should see a command window open and connect to Edge. If the Edge browser is already open, it will close it and open a new instance. Based on your error, I don't believe you are seeing this behavior, am I correct? If so, something may be blocking the WebDriver Server from launching locally (Defender??). Check the conditional setting serverPath. I could not get the Is64BitOperatingSystem to resolve, so I chose the correct path and removed the rest of the conditional, setting serverPath to the location of the MicrosoftWebDriver.exe.
If you have the incorrect path it will not make it past the "driver" instantiation. Somehow you are making it to the driver.Url call, I assume you are getting some resolution with that serverPath. So it is possible something on the local device is blocking MicrosoftWebDriver.exe from running.
Again, you should see a command prompt with proper communication logging displayed.
One last tip, you can go to MicrosoftWebDriver.exe and run it. Then you can go to: http://dev.modern.ie/testdrive/demos/webdriver/ and "Send Request" with the default values, which should be to create a session. You will see the results posted to the page and also see the logging of the communications in the command window.
Be sure to go to that page from a different browser than Edge since it will kill the existing Edge windows, including itself.
I have a little insight, but not a workaround or fix, yet...
in my case, the web driver server for IE conflicted with my web driver server for edge... and I still do not have a workaround... I have a cycle of tests that run on five different browsers.
when I tried to add edge, it would not run edge without crashing.
the web driver in the debug folder (for the base five including IE) name is IDENTICAL to the one that is included when I run Edge.
I do not know how to fix it and meet the testing requirements... YET.
bro mak

Selenium Webdriver + PhantomJS remains at about:blank for a specific site

I am trying to use PhantomJS with Selenium Webdriver and got success but for a specific website I see that it does not navigate to the URL. I have tried it with both Python and C#.
Python Code:
dcap = dict(webdriver.DesiredCapabilities.PHANTOMJS)
dcap["phantomjs.page.settings.userAgent"] = ("Mozilla/5.0 (Windows NT 6.2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36")
service_args = ['--load-images=false', '--proxy-type=None']
driver = webdriver.PhantomJS(executable_path="C:\\phantomjs.exe", service_args=service_args, desired_capabilities=dcap)
driver.get("https://satoshimines.com")
print driver.current_url
The output of this code snippet is: about:blank
Whereas it works fine for any other website.
Same code with C#:
IWebDriver driver = new PhantomJSDriver();
driver.Navigate().GoToUrl("https://satoshimines.com");
Console.WriteLine(driver.Url);
The output of the C# program is also same.
I am stuck here and need help.
Following is a complete code solution for c# -
PhantomJSDriverService service = PhantomJSDriverService.CreateDefaultService();
service.IgnoreSslErrors = true;
service.LoadImages = false;
service.ProxyType = "none";
driver = new PhantomJSDriver(service);
For me, the solution was as follows:
var service = PhantomJSDriverService.CreateDefaultService();
service.SslProtocol = "tlsv1"; //"any" also works
driver = new PhantomJSDriver(service);
I have no idea why the default sslv3 will not work. If you are sure the SSL certificates are valid, it is quite recommended not to ignore errors to protect against malicious certificates.
Update: For a very good explanation why SslProtocol should now be set to tlsv1 instead of the default sslv3, please take a look at the excellent cross link provided below by #Artjom B.
It seems I have found a solution to this. The problem was an SSL handshake problem.
By passing
'--ignore-ssl-errors=true' as a service_args to phantomjs solves the issue.
Thanks
this worked for me:
DesiredCapabilities capabilities = DesiredCapabilities.phantomjs();
capabilities.setJavascriptEnabled(true);
capabilities.setCapability(PhantomJSDriverService.PHANTOMJS_CLI_ARGS, new String[] {"--web-security=no", "--ignore-ssl-errors=yes", "--ssl-protocol=tlsv1"});
driver = new PhantomJSDriver(capabilities);
Ran into this issue on an application quite abruptly after running phantomjs 1.9.7 for months without incident. The solution? Update phantomjs to 2.0.0.

Categories