如何使用Selenium WebDriver选择软件包

时间:2018-06-22 05:05:46

标签: selenium selenium-webdriver

public class chrome {

public static void main(String[] args) throws InterruptedException {

    System.setProperty("webdriver.chrome.driver", "C:\\chromedriver.exe");
    WebDriver driver = new ChromeDriver();
    driver.get("https://neontv.co.nz");
    Thread.sleep(2000);
    driver.findElement(
            By.xpath("//*[@class='nv-nav-freetrial-2 nv-nav-item']"))
            .click();
    Thread.sleep(200);
    driver.findElement(
            By.xpath("//ul[@id='yui_patched_v3_11_0_2_1529643447183_22']"))
            .click();
    Thread.sleep(2000);
    driver.quit();

}

}

我无法在下一页上选择软件包。.我尝试更改xpath,但没有帮助..还有其他选择方法。有人可以帮忙吗

1 个答案:

答案 0 :(得分:0)

使用动作类,我能够解决此问题

driver.switchTo().defaultContent();
 Actions action = new Actions(driver);
 action.moveToElement(btnEnjoy).click().build().perform();