addArguments in selenium
Using addArguments method we can achieve result of the all
the methods in ChromeOptions/FirefoxOptions/InternetExplorerOptions class.
For Example, we can make the browser as headless, we can add proxy, we can add extensions, so on..
For Example, we can make the browser as headless, we can add proxy, we can add extensions, so on..
package
pack2;
import
org.openqa.selenium.WebDriver;
import
org.openqa.selenium.chrome.ChromeDriver;
import
org.openqa.selenium.chrome.ChromeOptions;
public class
ChromeOptionsEx
{
public static void
main(String[] args) {
System.setProperty("webdriver.chrome.driver", "D:\\PATH\\chromedriver.exe");
ChromeOptions fo = new
ChromeOptions();
//
disable the info bar
fo.addArguments("--disable-infobars");
//
create object to firefx driver, register options class
WebDriver driver = new
ChromeDriver(fo);
driver.get("https://bing.com");
}
}
Handle Browser notification
Lot of websites has started sending notifications these days. You get these notifications on desktop or device even when the concerned web page is not open in your browser.
These are also called as Web push notifications. These notifications looks like below in chrome browser: We have to use addArguments method to handle these kind of browser notifications,
package
pack2;
import
org.openqa.selenium.WebDriver;
import
org.openqa.selenium.chrome.ChromeDriver;
import
org.openqa.selenium.chrome.ChromeOptions;
public class ChromeOptionsEx
{
public static void
main(String[] args) {
System.setProperty("webdriver.chrome.driver", "D:\\PATH\\chromedriver.exe");
ChromeOptions fo = new
ChromeOptions();
fo.addArguments("--disable-notifications");
WebDriver driver = new
ChromeDriver(fo);
driver.get("https://drupal-stage-web.weather.com/en-IN");
}
}
No comments:
Post a Comment