自动轴银行网站(Automate axis bank website)

2019-11-04 04:51发布

嗨,我想用下面的序列和代码选择储蓄账户。 该脚本通过每次但点击保存所有未账户。 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();

Answer 1:

这对我的作品:

    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();


Answer 2:

你忘了调用perform()click()

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

您也可以尝试WebElement点击

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


文章来源: Automate axis bank website