I'm running an automation on mac and on ubunto (using cucumber, selenium web driver, junit)
during the automation I click a link with non http protocol
an "External protocol request" popup appears.
It blocks my test from testing the rest of the webpage.
How can disable this popup for all chrome profiles? even incognito\anonymous chrome?
I have tried to add "" to the /Users/eladb/Library/Application Support/Google/Chrome/Local State file.
protocol_handler":{"excluded_schemes":{.."waze":false,"mailto":false,..}
and also tried:
protocol_handler":{"excluded_schemes":{.."waze":ture,"mailto":false,..}
but even after a restart and running the test, the popup appears.
Create you driver instance with chrome options as follows:
ChromeOptions cChromeOptions = new ChromeOptions();
cChromeOptions.addArguments("--test-type");
WebDriver _driver=new ChromeDriver("path_to_your_Chrom_Driver", cChromeOptions);
I tried the 'Local State' file also not working. Someone pointed out the folder Default/Preferences file. Make your change there and it will work.
Related
I'm able to run selenium on non GUI centos/linux machine in headless mode.
I have been trying to run it with cache enable by passing below chromeoptions arguments.
chromeOptions.addArguments("user-data-dir=~/.config/google-chrome");
It has started fine and identified elements till login page(which is first page) and couldn't identify any locators after that.
Is it the right approach to run cache enabled selenium run?
It's not that super clear when you mention about executing your tests with cache enabled. However, adding the argument user-data-dir is the canonical way to use a specific Chrome Profile.
You can find a couple of detailed discussions in:
How to open a Chrome Profile through Python
How to use Chrome Profile in Selenium Webdriver Python 3
Adding those options helps me to prevent crashes and errors on a linux remote machine
ChromeOptions options = new ChromeOptions();
options.addArguments(
"--disable-gpu",
"--headless",
"--window-size=1920,1200",
"--ignore-certificate-errors",
"--disable-extensions",
"--no-sandbox",
"--disable-dev-shm-usage",
"--hide-scrollbars",
"--allow-running-insecure-content",
"--disable-infobars",
"--ignore-certificate-errors");
Webdriver driver = new ChromeDriver(options);
I'm running all my test suites on Jenkins which is deployed on AWS EC2 instance. There is a scenario where when I click on a button, new small window opens up and I'm doing assertion for the text visible inside the small newly opened window. But my tests are failing when I run using Headless mode. But, same scripts works fine when I run scripts locally without opting for headless browser.
The issue here is the scripts are failing because of headless browser since it's unable to capture text inside small window which has opened after click of button.
This class is extending InitiateDriver class which explained. Below class is trying to fetch text which is visible inside the new window which just opened after clicked on SignInWithGSuiteSSOClick() button.
Here is the code:
// click on a button
GSuiteobject.SignInWithGSuiteSSOClick().click();
String winHandleBefore = driver.getWindowHandle();
// Here trying to capture text inside new window opened up basically gmail window to enter email
String signInHeader = GSuiteobject.GsuiteSignInHeader().getText();
Assert.assertEquals(signInHeader, "Sign in");
GSuiteobject.GsuiteEmail().sendKeys("example#gmail.com");
InitiateDriver.java
ChromeOptions options = new ChromeOptions();
options.addArguments("--headless");
options.addArguments("--window-size=1920, 1080");
options.addArguments("--disable-gpu");
driver = new ChromeDriver(options);
The same code works in browser mode but not in headless. But the driver will be initialized but it fails only while capturing text. Please help me out I'm stuck here and unable to execute it on Jenkins as a headless browser.
Headless chrome browser's gmail UI will be different from actual gmail UI(latest). Hence it fails when we run headless chrome for automating gmail login since xpaths will differ. We can validate that by taking Screenshot by running on headless and normal browser.
I suggest to take screenshot using both headless and normal browser. To check on xpaths for headless we can try driver.getPageSource() method.
I have a problem with running my selenium test in headless mode with some specific profile (with extensions).
without headless, the script is working file (with specific profile), but with the headless mode, it is picking default profile which resulted in the failure of the script.
Tried some ways to solve this issue, but nothing worked.
chromeOptions.setAcceptInsecureCerts(true);
chromeOptions.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
chromeOptions.setCapability(CapabilityType.ACCEPT_INSECURE_CERTS, true);
chromeOptions.addArguments("--remote-debugging-port=23456"); - this resulted in error at this port.
code setup for starting chrome browser in headless mode.
chromeOptions.setExperimentalOption("excludeSwitches",
Arrays.asList("disable-sync", "enable-logging"));
chromeOptions.addArguments("--enable-sync");
chromeOptions.addArguments("--disable-logging");
chromeOptions.addArguments("--no-sandbox");
chromeOptions.addArguments("--disable-dev-shm-usage");
chromeOptions.addArguments("--headless");
chromeOptions.addArguments("--disable-gpu");
chromeOptions.addArguments("--window-size=1280,800");
chromeOptions.addArguments("--allow-insecure-localhost");
chromeOptions.addArguments("--remote-debugging-port=45447");
chromeOptions.setAcceptInsecureCerts(true);
chromeOptions.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
chromeOptions.setCapability(CapabilityType.ACCEPT_INSECURE_CERTS, true);
Adding extensions are not supported with headless run.
So, used "Xvfb" virtual frame buffer to mock the chrome UI.
Remove "--headless" while starting the browser instance.
When i tried to start on Firefox web driver its not starting its showing firefox default page
WebDriver dr = new FirefoxDriver();
dr.get("https://www.google.co.in/");
dr.manage().window().maximize();
its not starting its showing firefox default page
Below i attach output image screenshot
https://www.mozilla.org/en-US/firefox/43.0.4/firstrun/learnmore/
Firefox is one of the most compatible browsers with selemium, and at the same time, is one of the least compatible.
I say this because if you do not have the correct version of the selenium library to go with the version of firefox you are running, or vice-versa, it will always fail.
I would start by attempting to switch to a different version of Firefox. Selenium version 2.48.0 supports Firefox versions 24-41, so if your firefox version does not fit within that range, it is more than likely the problem.
I faced the same issue. The solution to this problem is to update the selenium version. When the page u mentioned i.e https://www.mozilla.org/en-US/firefox/43.0.4/firstrun/learnmore/ opens on firefox launch go to Options -> Addons -> Extensions. You will be able to see the Error there. I got "Forefox Webdriver could not be loaded and is disabled".
This was on Firefox 43 with selenium 2.44. Updating to selenium 2.51 rectified the issue.
Sorry, I cannot comment yet but I would like to help. I got the similar issue when I used selenium webdriver integrated in my python script. The problem was with credentials (particularly with the SSL protocols while declaring a new webdriver object). The code I used looked as the following:
driver = webdriver.PhantomJS(executable_path = "/opt/local/bin/phantomjs", service_args=['--ignore-ssl-errors=true'])
As you can see I use a key that ignores ssl errors. This solved my issue, so I am not sure what platform you use to write the code but hope you can find the similar call for the object.
I found the way how people handle untrusted certificates here. Particularly, for FireFox:
//It creates firefox profile
FirefoxProfile profile=new FirefoxProfile();
// This will set the true value
profile.setAcceptUntrustedCertificates(true);
// This will open firefox browser using above created profile
WebDriver driver=new FirefoxDriver();
driver.get("pass the url as per your requirement");
Hope it helps you!
Best.
-Petr.
Try this.. This will resolve the issue..
FirefoxProfile fpi = new FirefoxProfile();
fpi.setPreference("browser.startup.homepage_override.mstone", "ignore");
fpi.setPreference("startup.homepage_welcome_url.additional", "about:blank");
wd = new FirefoxDriver(fpi);
wd.get("http://www.google.com");
if you want to over-ride the properties of firefox, then,
1.first to find the list of browser properties, type "about:config" in the address url
2.use, setPreference method to set/assign the values..
I m using Selenium IE Webdriver.I want to delete "This is the initial page of webdriver server." from IEDriverServer.exe file of Selenium IE Webdriver. I opened the IEDriverServer.exe file in notepad++ and deleted that line from it and again add it in my classpath.But then i get this error:
org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
How can we do that.Please someone tell me.
You can't just edit an executable file like that. You have undoubtedly ruined the executable and now should redownload it from the Selenium site.
Regardless, this is expected behaviour. The IEDriver must have somewhere to go to begin with.
There is a setting that configures this URL called InitialBrowserURL. If this is not configured in your code, then the default is used.
Configure this to what you want. Most cases it can be configured to just go to the home page of your application.