public class MultipleWindowHandle
{
public static void main(String[] args)
{
System.setProperty("webdriver.chrome.driver", "E:\\NEWSEL\\chromedriver.exe");
// Create object of HashMap Class as shown below.
Map<String, Object> prefs = new HashMap<String, Object>();
// Set the notification setting it will override the default setting.
prefs.put("profile.default_content_setting_values.notifications", 2);
// Create object of ChromeOption class.
ChromeOptions Roptions = new ChromeOptions();
// Set the experimental option.
Roptions.setExperimentalOption("prefs", prefs);
// Open chrome browser.
ChromeDriver driver = new ChromeDriver(Roptions);
driver.get("https://my.monsterindia.com/login.html");
Set<String> id = driver.getWindowHandles();
Object[] data = id.toArray();
driver.switchTo().window((String)data[1]); driver.close();
}
}
Someone needs this for Capybara or Watir, you can pass the --disable-notifications as an argument like "--start-fullscreen", "--disable-infobars". The following workes:
Capybara.register_driver :chrome do |app|
args = ["--disable-notifications"]
Capybara::Selenium::Driver.new(app, {:browser => :chrome, :args => args})
end
This question was answered in the: "chromedriver-users" google forum. This is the working answer:
you can use:
Someone needs this for Capybara or Watir, you can pass the
--disable-notifications
as an argument like"--start-fullscreen", "--disable-infobars"
. The following workes: