0

我目前正在尝试使用 Readyapi 设置一个测试用例,这个自动化测试用例必须找到网站并登录,这一切都很好。我的问题是,如果登录它还必须检查是否出现注销按钮,那就是我收到错误的时候。

代码:

    import org.openqa.selenium.By 
    import org.openqa.selenium.WebDriver 
    import org.openqa.selenium.WebElement 
    import org.openqa.selenium.chrome.ChromeDriver 
    import org.openqa.selenium.support.ui.ExpectedCondition 
    import org.openqa.selenium.support.ui.WebDriverWait
    import org.openqa.selenium.WebDriverException;
    import org.openqa.selenium.chrome.ChromeOptions;

    import org.openqa.selenium.Alert;
    import org.openqa.selenium.JavascriptExecutor;
    import org.openqa.selenium.NoAlertPresentException;
    import org.openqa.selenium.NoSuchElementException;
    import org.openqa.selenium.NoSuchFrameException;
    import org.openqa.selenium.StaleElementReferenceException;

    // Creating Chrome driver object.
    System.setProperty("webdriver.chrome.driver","C:\\Training\\chromedriver.exe");
    WebDriver driver = new ChromeDriver();
    driver.manage().window().maximize()

    def  aUser = context.expand( '${#Project#username}' )
    def  aPass = context.expand( '${#Project#authPass}' )
    def  wUrl = context.expand( '${#Project#webUrl}' )

    String URL = "https://"+aUser+":"+aPass+"@"+wUrl;
    driver.get(URL);

    //*[@id="welcome"]/nav/div/div/ul[2]/li[2]/a
    driver.findElement(By.xpath("//*[@id='welcome']/nav/div/div/ul[2]/li[2]/a")).click();

    def email = context.expand( '${#Project#email}' )
    def pass = context.expand( '${#Project#password}' )

    //*[@id="inputEmail"]
    driver.findElement(By.xpath("//*[@id='inputEmail']")).sendKeys(email);
    //*[@id="inputPassword3"]
    driver.findElement(By.xpath("//*[@id='inputPassword3']")).sendKeys(pass);
    //*[@id="j_id0:idpPost1"]/div/div[3]/input
    driver.findElement(By.xpath("//*[@id='j_id0:idpPost1']/div/div[3]/input")).click();

    WebDriverWait wait = new WebDriverWait(driver, 2000);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[@id='logout-link']/span[2]")));

        driver.close();

错误: groovy.lang.missing propertyexception 没有这样的属性:类的错误预期条件:Script25

注意: 每次我更改某些内容时,错误中的脚本编号似乎都会更改。

任何帮助将不胜感激!

4

0 回答 0