9

我正在使用 Web 驱动程序管理器来设置 chrome 驱动程序。设置驱动程序时,我想添加一些chrome 选项?使用 Web 驱动程序管理器时我该怎么做?

我检查了 WebDriverManager API,但找不到任何线索..

4

3 回答 3

0
public void WebDriverManagerTest()
{
    //setup the chromedriver using WebDriverManager
    WebDriverManager.chromedriver().setup();

    //Create Chrome Options
    ChromeOptions option = new ChromeOptions();
    option.addArguments("--test-type");
    option.addArguments("--disable-popup-bloacking");
    DesiredCapabilities chrome = DesiredCapabilities.chrome();
    chrome.setJavascriptEnabled(true);
    option.setCapability(ChromeOptions.CAPABILITY, option);

    //Create driver object for Chrome
    WebDriver driver = new ChromeDriver(option);

    //Navigate to a URL
    driver.get("http://toolsqa.com");

    //quit the browser
    driver.quit();
}

找到答案..检查上面!

于 2019-08-17T07:27:50.413 回答
0

来自https://pypi.org/project/webdriver-manager/,在 .install() 之后传入

from selenium import webdriver
from webdriver_manager.opera import OperaDriverManager

options = webdriver.ChromeOptions()
options.add_argument('allow-elevated-browser')
options.binary_location = "C:\\Users\\USERNAME\\FOLDERLOCATION\\Opera\\VERSION\\opera.exe"

driver = webdriver.Opera(executable_path=OperaDriverManager().install(), options=options)
于 2021-12-24T11:36:19.600 回答
0

这是示例代码:

public class Test1{
    
    @Test
    public void WebDriverManagerTest()
    {
        //setup the chromedriver using WebDriverManager
        WebDriverManager.chromedriver().setup();
        //Create driver object for Chrome
        WebDriver driver = new ChromeDriver();
        //Navigate to a URL
        driver.get("http://toolsqa.com");
        //quit the browser
        driver.quit();
    }
}
于 2020-08-04T11:51:29.203 回答