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
Related
For non-headless Chrome, when running an NUnit test with the debugger attached, this works fine.
For headless Chrome (without a debugger attached), it doesn't - there's nothing in driver.Manage().Logs.GetLog(LogType.Browser);.
My test setup is as follows:
ChromeOptions chromeOptions = new();
chromeOptions.AddArguments("headless");
IWebDriver driver = new ChromeDriver(chromeOptions);
// Set a window size (possibly not relevant but including it here just in case)
var size = driver.Manage().Window.Size;
size.Width = 1366;
size.Height = 768;
driver.Manage().Window.Size = size;
// Do the test which should cause a browser error
driver.Navigate().GoToUrl("invalid url");
ILogs logs = driver.Manage().Logs;
var errors = logs.GetLog(LogType.Browser).Where(x => x.Level == LogLevel.Severe).Select(x => x.Message).ToList();
Assert.That(errors.Count, Is.EqualTo(1));
As I mentioned above, this works in non-headless mode. In headless mode, there are no logs available at all.
A few things I've tried to make it work headlessly, to no avail yet:
chromeOptions.AddArguments("--log-level=ALL");
chromeOptions.AddArguments("--enable-logging --v=1");
chromeOptions.SetLoggingPreference(LogType.Browser, LogLevel.All);
What should I do to allow browser errors to be picked up in headless mode?
I'm having issues testing iPhone on BrowserStack with tests written in C# with Selenium and Protractor-net.
The test starts running and after it opens the webpage to my website, it just hangs and never moves on to the StringAssert step. There are no errors when this happens. I must manually stop my test and the session in BrowserStack to continue.
I tried turning on logging from within BrowserStack's capabilities, but no errors are returning and the console log is empty. I've tried multiple configs of iPhones too.
Note, this sample test works fine with Android Google Pixel 2 and Windows 10 testing on BrowserStack, just iPhone's are giving me this problem.
Here is my sample test:
class Class1
{
[Test]
public static void FirstTest()
{
IWebDriver driver;
DesiredCapabilities capability = new DesiredCapabilities();
capability.SetCapability("browserName", "iPhone");
capability.SetCapability("device", "iPhone 6S");
capability.SetCapability("realMobile", "true");
capability.SetCapability("os_version", "11.4");
capability.SetCapability("browserstack.console", "errors");
capability.SetCapability("browserstack.user", "");
capability.SetCapability("browserstack.key", "");
driver = new RemoteWebDriver(new Uri("http://hub-cloud.browserstack.com/wd/hub/"), capability);
driver.Manage().Timeouts().AsynchronousJavaScript = TimeSpan.FromSeconds(10);
NgWebDriver ngdriver = new NgWebDriver(driver);
ngdriver.Navigate().GoToUrl("https://myproduction.website/");
StringAssert.Contains("MyTitle", ngdriver.Title);
NgWebElement query = ngdriver.FindElement(NgBy.Model("employeeCode"));
query.Clear();
query.SendKeys("Browserstack");
Console.WriteLine(ngdriver.Title);
ngdriver.Quit();
}
}
I understand you are running Protractor tests on real iOS devices. Protractor injects JavaScripts using execute_async method. The execute_async method is not fully supported by Appium due to which you may be seeing failures. You will find more details on the issue at the links below:
https://github.com/angular/protractor/issues/2840
https://github.com/angular/protractor/issues/1736
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");
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
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();