用不同的方法编写硒脚本

时间:2019-03-23 10:55:04

标签: selenium selenium-webdriver

我想用两种方法编写一个硒自动化脚本。 第一种方法仅包含登录代码 在第二种方法中,剩余脚本 请告诉解决方案?

WebElement username = wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("login_username")));
        username.sendKeys(userName);
        WebElement Password = wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("login_password")));
        Password.sendKeys(password);
        seleniumAuto.captureScreenshot(driver, "loginDetailsFill");
        WebElement loginBtn = wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("landing-login")));
        loginBtn.click();

预期结果- 方法1-

login(){
WebElement username = wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("login_username")));
        username.sendKeys(userName);
        WebElement Password = wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("login_password")));
        Password.sendKeys(password);
        seleniumAuto.captureScreenshot(driver, "loginDetailsFill");
        WebElement loginBtn = wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("landing-login")));
        loginBtn.click();

}  

方法2-

fileDownload(){
    WebElement reportDownloads = wait
                    .until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("#module-tab-my_downloads")));
            reportDownloads.click();

}

0 个答案:

没有答案