Hi i am trying to connect to remote webdriver on browserstack using Selenium but whenever the page loads in Chrome and Firefox i get a security message (see images below).
my URL is starting with https:// (when i manually open the browser i have to accept the certificates and continue before the webpage loads)
i have added this line to my code but it does not seem to make any difference:
capability.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
capability.setCapability(CapabilityType.SUPPORTS_NETWORK_CONNECTION, "true");
capability.setCapability(CapabilityType.ACCEPT_INSECURE_CERTS, true);
NOTE: This issue only occurs then the tests are run on the GoCD pipeline. when running on intellij it all works fine
error:
org.openqa.selenium.WebDriverException: Reached error page: about:neterror?e=nssFailure2&u=https%3A//transport....
in chrome i see this:
and in firefox i get a similar message:
Can you try adding something as below and test:
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments("ignore-certificate-errors");
capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);
options.addArguments("--test-type");
capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.AddArguments("disable-gpu");
chromeOptions.AddArguments("window-size=1980,1080");
Driver = new ChromeDriver(chromeOptions);
i have found the problem for anyones future reference.
This is because DNS requests were not forwarded for our host name on GocD.
Related
I'm trying to load a webpage using Selenium ChromeDriver. It worked for the past 2 weeks until today I get an error about my connection not being secure and the page doesn't load. By making some research it seems to have something to do with the SSL certificate. However if I launch the same page in Chrome without using Selenium, the connection shows as secure.
I tried to use DesiredCapabilities and ChromeOptions to launch the driver with different options, but none seems to be working up to now.
This code shows a resume of all DesiredCapabilities and ChromeOptions I tried up to now.
ChromeOptions options = new ChromeOptions();
options.setAcceptInsecureCerts(true);
options.setUnhandledPromptBehaviour(UnexpectedAlertBehaviour.ACCEPT);
options.addArguments("--allow-insecure-localhost");
options.addArguments("--ignore-certificate-errors");
options.addArguments("--allow-running-insecure-content");
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
capabilities.setCapability(CapabilityType.ACCEPT_INSECURE_CERTS,
true);
capabilities.setCapability(CapabilityType.SUPPORTS_NETWORK_CONNECTION,
true);
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
wDriver = new ChromeDriver(capabilities);
I don't get any different results using these options or not. I get no error message besides a windows pop up in Chrome on the left of navigation bar saying the connection is not secure.
This is the error showing on the browser
What am I missing?
I need to start Firefox / Chrome using remote webdriver with a specific browser language. I know how to do it while running locally. But is it possible to start a remote webdriver with specifying browser language.
This is how object creation done is RemoteWebDriver,
WebDriver driver = new RemoteWebDriver(new URL("http://localhost:PORT_NUMBER/"), DesiredCapabilities.firefox());
Profiller is the key here,
var fp = new FirefoxProfile();
fp.SetPreference("intl.accept_languages", "en-au");
desiredCap.SetCapability(FirefoxDriver.ProfileCapabilityName,fp.ToBase64String());
your code seems specific to chrome so you can use this, I hope this might help you,
var options = new ChromeOptions();
options.AddArgument("--lang=zh"); // this sets US english
desiredCap.SetCapability(ChromeOptions.Capability, options);
WebDriver driver = new RemoteWebDriver(new URL("http://localhost:PORT_NUMBER/"), desiredCap.chrome());
Possible duplicate of How to set Browser Language using RemoteWebDriver
My application has both http and https ssl certificate. To handle https link using Selenium 3.4.0 I have used following code for firefox. Firefox browser is opening, but it is showing 'Secure Connection Failed'
System.setProperty("webdriver.gecko.driver","C:\\Users\\vidhya.r\\Desktop\\Automation\\Jars\\geckodriver.exe");
FirefoxProfile pro = new FirefoxProfile();
pro.setAcceptUntrustedCertificates(true);
WebDriver driver = new FirefoxDriver(pro);
driver.get("https://192.168.8.115:7077/final/#!");
Below solution will definitely work for your chrome browser.
WebDriverManager.chromedriver().setup();
ChromeOptions options = new ChromeOptions();
options.addArguments("--ignore-certificate-errors");
System.setProperty("webdriver.chrome.driver",
System.getProperty("user.dir")+"/Drivers/chromedriver.exe");
driver = new ChromeDriver(options);
driver.get(applicationURL);
driver.manage().window().maximize();
There are two instances of the same site, only difference is, that one uses a valid, another one uses an invalid HTTPS/SSL certification. I tried to open both in headless ChromeDriver 2.31 and found it opens site only with valid SSL certification.
<chromepath> --headless --remote-debugging-port=9101 --disable-gpu <siteurl>
Code above opens a site https://chrome-devtools-frontend.appspot.com/serve_file/identification_number with a preview from the given website.
I use this to ignore certificate problems, but I get the same blank page for this site in ChromeDriver.
caps.setCapability("chrome.switches", Arrays.asList("--ignore-certificate-errors"));
Late to the party, maybe it is useful to someone, the below parameter works for me.
acceptInsecureCerts: true
you can use DesiredCapabilities
DesiredCapabilities handlSSLErr = DesiredCapabilities.chrome ();
handlSSLErr.setCapability (CapabilityType.ACCEPT_SSL_CERTS, false);
WebDriver driver = new ChromeDriver (handlSSLErr);
Try it, may be it helps you.
Second way:
System.setProperty("webdriver.chrome.driver", "E:\\software and tools\\chromedriver_win32\\chromedriver.exe");
ChromeOptions option= new ChromeOptions();
option.addArguments("headless");
option.addArguments("ignore-certificate-errors");
WebDriver d=new ChromeDriver(option);
//d.get("http://expired.badssl.com/");
d.get("https://expired.badssl.com/");
Image for reference
From what I understand so far, Chrome Driver always starts without any stored browser cookies.
I need the driver start with all the cookies stored by Chrome.
I wonder if there is any way to start the driver with the cookies that are already stored? I'm using C# with .net 4.5.
Yes we can do it by invoking saved chrome profile just like firefox profile. below are steps i noted when i am doing bit back ago
in Java, we can do it by using ChromeOptions and Chrome Profile. In chrome navigate to chrome://version/ It will display profile path and Executable path.
As per my working on this, The profile path is \Local\Google\Chrome\User Data\Profile 3 This is displaying what is displayed when i navigate to chrome://version/ in normal chrome browser. In this profile, i navigated to stackoverflow and saved credentials. So used below code
Map<String, Object> prefs = new HashMap<String, Object>();
prefs.put("binary", "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe");
System.setProperty("webdriver.chrome.driver", "E:\\selenium_setups\\poi-3.12\\chromedriver.exe");
ChromeOptions options = new ChromeOptions();
options.setExperimentalOption("prefs", prefs);
options.addArguments("user-data-dir=C:\\Users\\murali\\AppData\\Local\\Google\\Chrome\\User Data\\Profile 3");
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
WebDriver driver = new ChromeDriver(capabilities);
//WebDriver driver = new ChromeDriver(options);
driver.get("http://stackoverflow.com/");
As per my understanding, i excepted stackoverflow.com page displayed as logged in. but for first time, i am not logged in. so cross checked with chrome://version/ in chrome opened by driver, profile path is displayed as
\Local\Google\Chrome\User Data\Profile 3\Default . then logged manually in that profile it self, which is opened by webdriver and executed gain by closing it.
Finally, page is displayed as logged in. So it may be in java, i hope it will helps you to try in C# .