自动化轴银行网站

时间:2016-03-22 05:39:48

标签: selenium-webdriver testng

您好我想使用以下顺序和代码选择保存帐户。脚本每次都会传递,但保存的帐户根本没有被点击。 1.开放轴银行网站。 2.打开产品下拉列表3.打开其中的帐户部分4.单击储蓄帐户5.打开下一页的当前帐户部分

driver.get("http://www.axisbank.com/");
Actions action=new Actions(driver);
WebElement prod=driver.findElement(By.id("product"));
WebElement saving=driver.findElement(By.xpath("html/body/form/div[5]/div[1]/div[3]/div/div[1]/div[2]/div/div/ul[2]/ul/li[1]/a"));
WebElement account=driver.findElement(By.xpath("html/body/form/div[5]/div[1]/div[3]/div/div[1]/div[2]/div/div/ul[1]/li[1]/a"));
action.moveToElement(prod).moveToElement(account).moveToElement(saving).click();
Action composite=action.build();
composite.perform();

2 个答案:

答案 0 :(得分:0)

这对我有用:

    Actions action=new Actions(driver);
//This is just to wait for that mobile window to go..You can add some other logic for that to disappear
            Thread.sleep(15000);
            WebDriverWait wait=new WebDriverWait(driver, 15,3000);
            WebElement prod=wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath(".//span[text()='Products']")));
            WebElement saving=driver.findElement(By.xpath(".//a[starts-with(@title,'Savings Accounts')]"));
            WebElement account=driver.findElement(By.xpath(".//a[text()='Accounts']"));
            action.click(prod).perform();
            action.moveToElement(account).perform();
            action.moveToElement(saving).click().perform();

答案 1 :(得分:0)

您忘记在perform()

上致电click()
action.moveToElement(prod).moveToElement(account).moveToElement(saving).click().perform();

您也可以尝试点击WebElement

action.moveToElement(prod).moveToElement(account).moveToElement(saving).perform();
saving.click();