I'm working with Selenium, Java and Browserstack. Usually I develop in MacOS and I improve the compatibility with the remote browser. I'm trying to execute the same test cases that are working properly in MacOS, into a Windows remote machine.
The problem appears when I let a form incomplete because and I have clicked on a Cancel button to back again to the previous page. In this scenario the default chrome alert appears:
I have tried the Chrome option:
options.addArguments("--disable-notifications");
Also:
options.addArguments("--disable-popup-blocking");
And with:
prefs.put("profile.default_content_settings.popups", 0);
I know I can use a condition in the cancel button associated to the system configuration, where the selenium code accept the alert, but I'm searching an option more cleaning and easy.
Do you know any other option, capability or whatever, that could block those pop-ups but not the others?
Thank you in advance.
EDIT NOTE
It is something related with Chrome pop-ups only.
Please try
prefs.put("profile.default_content_setting_values.notifications", 2);
Related
I am trying to run the org.openqa.selenium.firefox.FirefoxDriver in Java.
I would like to open a browser window without the address bar and other functionalities like page-forward and so on.
Actually I would like to have a plain window with the displayed web content and even disabled context menu.
How to archive that.
I tried with the code:
FirefoxOptions op = new FirefoxOptions()
.addPreference("browser.startup.page", 1)
.addPreference("browser.startup.homepage", "https://google.com");
WebDriver driver = new FirefoxDriver();
but could not find any good, easy understandable documentation for preferences or arguments (addArgument(...)).
Could anyone give me a hint here?
These resources also did not give me a good understandable help:
https://developer.mozilla.org/en-US/docs/Web/WebDriver/Capabilities/firefoxOptions
https://searchfox.org/mozilla-central/source/modules/libpref/init/all.js
How to correctly use FirefoxOptions() and its arguments to pass it to the FirefoxDriver() constructor
Other threads I found on the internet are many years old.
As bonus, the same links for Chrome would also be appreciated.
This is a solution what I almost perfectly want. It does not deal with Selenium/Selenide, which is fully ok with me. I made it work nicely with Chrome browser.
See: https://github.com/greyshine/javaspring-embedded-browser
Most interesting files are the index.html and BrowserAdaptor.java.
What I still miss:
A nice way independent on the OS on how to locate the executable for the browser; see application.properties
Firefox does not open with a pure screen but still has tabs and some browser functions. What would be the startup parameters (see application.properties) for firefox to correctly start.
Same story for the Edge browser. Startup parameters, etc...
Bringing Selenide into the question was based, that I seen that this must be somehow possible.
I am trying to get Selenium WebDriver to find and use a browser window that is already open before the script executes. I am writting in Java.
I am using selenium-server 2.37.0 and the browser is IE8. I am open to using the Chrome browser as well.
Anyway, I have tried opening a driver instance and then looking for the window handles in the usual way (Set handles = driver.getWindowHandles();) but this only finds the hadle of the window that the driver opened. I have also just tried to switchTo the window by the window cannot be found.
The reason I want to use a pre-opened window is because when I execute my script, for some reason the browser won't let it click a link (It may be because the link is to an https address and sends a username and a token). When the script finishes the webpage won't respond to me manually clicking the link either.
I am able to manualy navigate to the link and click it the link works fine, so my thinking is that I can navigate to the page that I want and then kick of the scripts from there, but I need the webdriver to use this browser window that I used.
I cannot navigate the to link directly with Selenium because the link resided behind a secure server. I have to log in first then click the link and this is where I am having the problem.
Unfortunately, as of 2.37.1 (December 2013), it cannot be done.
There is an official feature request for this in the Selenium project (and it's even the most starred one), but it has not been done yet.
You can identify a browser window by windowHandle and switch between several Windows while testing.
You can print out all existing windowHandles (in your case it might be one) and then access it.
This solution worked for me (using Selenium 3.4.0):
Object[] handles = driver.getWindowHandles().toArray();
String windowHandle = handles[0]+"";
driver.switchTo().window(windowHandle);
After switching to your browser window you should be able to continue your test.
It relys on correctness of your webdriver- if you opened an Edge window the driver you use should be an EdgeDriver.
I am looking for how to open selenium webdriver in a new tab of a firefox already opened. I aim to do that beacause when my java program (webdriver) open firefox, i have to set profile params in my program. To do this, i must every time log on in a dialog frame, because i have installed cntlm.
In short, I want to open firefox in a new tab.
Thaks a lot!
Please watch this Selenium feature ticket for progress.
Issue 18: Allow webdriver to attach to a running browser
Your summary "In short, I want to open firefox in a new tab." is ambiguous and confusing, if you are looking for how to open new tab, see this question.
I'm testing web application with Selenium Webdriver (IE). After signing off, application closes the browser, but quiting the webdriver cause crash popup for IEDriverServer.exe which hangs the flow.
Is there's a way to unload the IEDriverServer.exe after browser was closed?
You can handle this in various ways. One logic i can think of is to do getWindowHandles() and call driver.quit() based on the window count. In your case after logoff it will be null.
I had this problem with an earlier version, which version are you using? There may be a newer version of IEServerDriver than what you have. I placed mine in a directory that I then added to system PATH and have no troubles with Chromedriver or IEServerDriver.
Don't know exact solution but, for Workaround, you can try this out :
use driver.close()
If first option doesn't work then open the browser once again and use driver.quit() or driver.close().
I'm trying to test a Java web app using Selenium 2.16.1. When Selenium opens Firefox, I see a band at the top of the page with message "Will you help improve Mozilla Firefox"
For some reason this breaks
selenium.click("id=submit");
selenium.waitForPageToLoad("60000");
which is trying to log in - it becomes a no-op, and the test fails because it's then expecting to have logged in. If I break on the click line and clear the 'will you help' band before continuing then the form submit succeeds.
Is there a way to suppress this band from appearing? (I expect that would mean setting a property in Firefox's default profile - where do I find that?) Or is there a way to get Selenium to spot and dismiss this first? Thanks! I'm using Firefox 9.0.1.
Solved - thanks Danny! Just in case it isn't clear from the answers and comments below:
This was an issue with 2.16.1 and IMO the best solution is to upgrade to 2.17 or later.
Peter points out below that this question is highly ranked for the "Will you help" message itself. If you're looking to disable it:
Firefox 9/10+: http://developers.sugarcrm.com/wordpress/2012/01/23/howto-disable-the-mozilla-firefox-telemetry-feature/ (and please vote up Peter's answer)
Firefox 6-8/9 or earlier: https://wiki.mozilla.org/Security/Reviews/Firefox6/ReviewNotes/telemetry (please vote up Danny's answer)
This is the telemetry feature, and the prompt is controlled by the toolkit.telemetry.prompted property:
https://wiki.mozilla.org/Security/Reviews/Firefox6/ReviewNotes/telemetry
You can set it via prefs.js:
http://kb.mozillazine.org/Prefs.js_file
Also relevant:
http://code.google.com/p/selenium/issues/detail?id=3144
The link referenced by #Danny Thomas is now out of date (it only applies to Firefox 6/7/8).
To get rid of the prompt, add the following lines to prefs.js in your firefox user profile directory.
user_pref("toolkit.telemetry.enabled", false);
user_pref("toolkit.telemetry.prompted", 2);
user_pref("toolkit.telemetry.rejected", true);
Note that the prompted setting has changed from 'False' to '2'.
Note: This also applies to the Firefox ESR product (tested on 10.0.5).
Source : http://developers.sugarcrm.com/wordpress/2012/01/23/howto-disable-the-mozilla-firefox-telemetry-feature/
I found out a little workaround. Use:
WebDriver driver;
...
WebElement elem = driver.findElement(By.id("submit"));
elem.sendKeys(Keys.RETURN);
it's like hitting "Enter" after getting to the element with the Tab key.
Danny
I was also facing same problem.
Solution for this is Use latest Selenium Server jar file (selenium-server-standalone.jar).
So it will work properly with latest firefox version and at the top of the page "Will you help improve Mozilla Firefox" message will not be displayed.