I need to launch IE browser and click on IE settings option and do some action. I launched IE browser but not able to click on Settings as inspect element is only restricted to webelements but not to IE settings tools.
Does anyone know solution for this?
You can try pressing (ALt+X) command using any Robot or Action Class once you lauch your browser. It will open setting tab.
I try to search but did not get any way to access IE options and settings using Selenium.
If we talk from a browser side, Than browser will also not allow any automation to access settings.
Someone can miss use it and try to change browser settings without informing the user. Than it can be a security related issue.
Although, It is not possible to access browser setting panel.
But We can achieve some scenario using desired capability:
DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer();
//Examples
capabilities.setCapability(InternetExplorerDriver.NATIVE_EVENTS, false);
capabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
capabilities.setCapability(InternetExplorerDriver.IGNORE_ZOOM_SETTING, true);
capabilities.setCapability("allow-blocked-content", true);
capabilities.setCapability("allowBlockedContent", true);
capabilities.setCapability("ignoreZoomSetting", true);
capabilities.setCapability("ignoreProtectedModeSettings", true);
capabilities.setCapability("requireWindowFocus", true);
capabilities.setCapability("enablePersistentHover", false);
capabilities.setBrowserName(DesiredCapabilities.internetExplorer().getBrowserName());
System.setProperty("webdriver.ie.driver", "C:\\IEDriverServer.exe");
//it is used to initialize the IE driver
WebDriver driver = new InternetExplorerDriver(capabilities);
Note: Please provide exact details what you want to achieve.
As per your requirement >> add new entry to add site to apps option in tools
************ Solution ***********
Robot robot = new Robot();
robot.keyRelease(KeyEvent.VK_ALT);
robot.keyPress(KeyEvent.VK_X);
for (int i = 1; i <= 5; i++) {
robot.keyPress(KeyEvent.VK_DOWN);
robot.keyRelease(KeyEvent.VK_DOWN);
}
robot.keyPress(KeyEvent.VK_ENTER);
Thread.sleep(1000);
robot.keyRelease(KeyEvent.VK_ESCAPE);
Note: Above code will do, if not please handle according to your requirement.
Related
I am facing an weird issue. I have a selenium suite to execute on multiple browsers. It works fine of chrome and Firefox. But in case of IE, the web page under test gets shrunk (web page resize) making elements hidden. Hence facing NoSuchElementException.
I have already tried executing on full screen. No help.
Please help in solving this issue.
Thanks,
Praveen
Don't know the exact reason for that, however, suggested workaround would be to implement pre-execution method for your test which would take care of all your browser different configurations. For example, if you are using Java with Selenium and JUnit5, it might be:
#BeforeEach
void beforeTestExecution() {
DesiredCapabilities desiredCapabilities = DesiredCapabilities.internetExplorer();
desiredCapabilities.setCapability(
CapabilityType.ForSeleniumServer.ENSURING_CLEAN_SESSION, true);
driver = new InternetExplorerDriver(desiredCapabilities);
// Navigate to URL
driver.get("http://www.yoursite.com");
// Maximize your website window before test.
driver.manage().window().maximize();
}
Or:
#BeforeEach
void configBrowser() {
DesiredCapabilities desiredCapabilities = DesiredCapabilities.internetExplorer();
desiredCapabilities.setCapability(
CapabilityType.ForSeleniumServer.ENSURING_CLEAN_SESSION, true);
driver = new InternetExplorerDriver(desiredCapabilities);
// Start Internet Explorer maximized.
driver.manage().window().maximize();
}
I am using the below code to enable popup blocker. But this doesn't work.
Map<String, Object> prefs= new HashMap<String,Object>();
prefs.put("profile.default_content_setting_values.popups", 2);
ChromeOptions coptions= new ChromeOptions();
coptions.setExperimentalOption("prefs", prefs);
driver= new ChromeDriver(coptions);
I found a simple walkaround for this problem. We can find the window popups via WindowHandles and using a loop, we can switch to that window, close it and return back to the parent window. This also helps when the number of popup ads is varying.
I have included firebug when launching firefox driver and it works very fine with latest selenium web driver 3.0 but meanwhile it also opens new firebug tab every time when launching browser.
As code says, i have included firebug file and added this extension in created profile. Is there any way to close the firebug tab automatically after launching the browser? If there is no automatic way then i need to use tweak to close window named "Firebug" right?
Code:
File file = new File("./firebug-2.0.17-fx.xpi");
System.setProperty("webdriver.gecko.driver", config.getStringProperty("geckodriver.path"));
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
FirefoxProfile profile = new FirefoxProfile();
profile.addExtension(file);
capabilities.setCapability(FirefoxDriver.PROFILE, profile);
capabilities.setCapability("marionette", true);
webDriver = new FirefoxDriver(capabilities);
You can set the "showFirstRunPage" flag to "false" in your porfile.
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("extensions.firebug.showFirstRunPage", false);
Here is a link to all firebug preferences you can set.
Firebug Preferences
An other solution is to set the "currentVersion" to a big number like this.
profile.setPreference("extensions.firebug.currentVersion", "999");
I prefer the first on ;)
I was looking for automatically closing Firebug window but i think its not possible so posting an answer to handle opened windows after launching firebox browser with firebug capabilities, unfortunately you need to deal with extra lines of code due to this issue :)
Below solution it works fine, just use it like below:
Working code:
File file = new File("./firebug-2.0.17-fx.xpi");
System.setProperty("webdriver.gecko.driver", config.getStringProperty("geckodriver.path"));
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
FirefoxProfile profile = new FirefoxProfile();
profile.addExtension(file);
capabilities.setCapability(FirefoxDriver.PROFILE, profile);
capabilities.setCapability("marionette", true);
webDriver = new FirefoxDriver(capabilities);
// Close the firebug window
Thread.sleep(4000); // Firebug window takes time to open it
Set <String> windows = webDriver.getWindowHandles();
String mainwindow = webDriver.getWindowHandle();
for (String handle: windows) {
webDriver.switchTo().window(handle);
if (!handle.equals(mainwindow)) {
webDriver.close();
}
}
webDriver.switchTo().window(mainwindow);
I am using selenium to automate a functionality on my webpage.
I am downloading certain files using selenium. But as soon as a download completes, I can see a pop up notification on my web page that the download is complete.
enter image description here
Kindly suggest using selenium, I can I remove this pop up notification?
I am setting the following firefox profile:
FirefoxProfile firefoxProfile = new FirefoxProfile();
firefoxProfile.setPreference("browser.download.folderList", 2);
firefoxProfile.setPreference("browser.download.manager.showWhenStarting", false);
firefoxProfile.setPreference("browser.download.manager.useWindow", false);
firefoxProfile.setPreference("browser.download.manager.showAlertOnComplete", false);
firefoxProfile.setPreference("browser.download.manager.closeWhenDone", true);
firefoxProfile.setPreference("browser.download.dir", downlodeLocation);
firefoxProfile.setPreference("browser.helperApps.neverAsk.openFile",
"application/bin,application/binary,text/comma-separated-values,application/octet-stream,text/csv,application/x-msexcel,application/excel,application/x-excel,application/vnd.ms-excel,text/html,text/plain,application/csv,text/anytext");
firefoxProfile.setPreference("browser.helperApps.neverAsk.saveToDisk",
"application/bin,application/binary,text/comma-separated-values,application/octet-stream,text/csv,application/x-msexcel,application/excel,application/x-excel,application/vnd.ms-excel,text/html,text/plain,application/csv,text/anytext");
Any help will be appreciable.
Thanks
You can do it via the browser settings
Type about:config in the address bar. Search for browser.download.animateNotifications or browser.download.manager.showAlertOnComplete and set them to false by right click -> toggle.
Problem Description - Upon clicking a link on the page, popup got blocked automatically.
file = new File("tools/chromedriver.exe");
System.setProperty("webdriver.chrome.driver", file.getAbsolutePath());
caps.setCapability("ignoreZoomSetting", true);
caps.setCapability("nativeEvents", false);
driver = new ChromeDriver(caps);
Environment used – Selenium WebDriver – 2.43.0 ChromeDriver, Windows 7
Note – it is working fine on Firefox & IE, this issue is happening on Chrome only.
Please assist on this.
This is a Chrome Option to disable all popups for the site
Open Chrome.
Find a page that has pop-ups blocked for you.
At the end of the address bar, click the pop-up blocker icon chrome op-up
locked.
Click the link for the pop-up window you'd like to see.
To always see pop-ups for the site, select Always show pop-ups from [site].
Once you have this set use the profile it is saved against to load for the test
Another option is to open the site and Shift F5 to do a Cache Refresh
Load a Profile. The code below is C# and you haven't specified a language. Please see the links provided for Java examples
ChromeOptions options = new ChromeOptions();
userDataPath = "C:/Users/user_name/AppData/Local/Google/Chrome/User Data";
options.AddArguments("user-data-dir=" + userDataPath);
options.AddArguments("--start-maximized");
driver = new ChromeDriver("pathToChromeDriver", options);
You can pass the chromeOption to allow pop-up as shown in below:
Map<String, Object> prefs = new HashMap<String, Object>();
prefs.put("profile.default_content_setting_values.popups", 1);
ChromeOptions options = new ChromeOptions();
options.setExperimentalOption("prefs", prefs);
WebDriver driver = new ChromeDriver(options);