Selenium Web Driver: findElement(By.name … and headless browser

前端 未结 4 516
借酒劲吻你
借酒劲吻你 2021-01-21 10:25

I\'m trying to follow the Selenium Webdrive Tutorial

http://www.toolsqa.com/selenium-webdriver/headless-browser-testing-selenium-webdriver/

There is a simple te

4条回答
  •  半阙折子戏
    2021-01-21 10:50

    Use xpath instead of name.

    try to use this code:

      WebElement searchBox = unitDriver.findElement(By.xpath("//input[@name='q']"));
    

    For search button click:

        // find the search button
        WebElement button = unitDriver.findElement(By.xpath("//input[@value='Google Search']"));
    
        // Click the button
        button.click();
    

提交回复
热议问题