How to use different webdrivers based on environment

前端 未结 3 1348
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-27 01:50

I use selenium-jupiter. I am getting a webdriver from method arguments like this:

@Test
public void testWithChrome(ChromeDriver chromeDriver) {
          chromeD         


        
3条回答
  •  说谎
    说谎 (楼主)
    2021-01-27 02:43

    You can do that with WebDriverManager that comes with this extension.

        @BeforeEach
        public void setUp()
        {
            switch(browser)
            {
                case "chrome" -> 
                    {
                    WebDriverManager.chromedriver().setup();
                    driver = new ChromeDriver();
                    }
                case "firefox" ->
                    {
                    WebDriverManager.firefoxdriver().setup();
                    driver = new FirefoxDriver();
                    }
                case "edge" ->
                    {
                        WebDriverManager.edgedriver().setup();
                        driver = new EdgeDriver();          
                    }
            }
                driver.manage().window().maximize();
       }
    

提交回复
热议问题