[英]Testing java class using selenium and cucumber
用戶應該能夠 select web 站點的首選語言和內容應該使用以下 web 站點加載所選語言?
這是我當前的代碼如何修改以匹配這種情況?
ublic class Steps {
WebDriver driver;
@Given("^Open the Firefox and launch the application$")
public void open_the_Firefox_and_launch_the_application() throws Throwable
{
System.setProperty("webdriver.gecko.driver", "E://Selenium//Selenium_Jars//geckodriver.exe");
driver= new FirefoxDriver();
driver.manage().window().maximize();
driver.get("https://www.gov.lk/welcome.html");
}
@Then("^Reset the credential$")
public void Reset_the_credential() throws Throwable
{
driver.findElement(By.name("btnReset")).click();
}
}
該元素是啟用了JavaScript的元素,因此要在元素上click()
,您需要對elementToBeClickable()
使用WebDriverWait ,並且可以使用以下任一定位器策略:
cssSelector
:
new WebDriverWait(driver, 10).until(ExpectedConditions.elementToBeClickable(By.cssSelector("a.english"))).click();
xpath
:
new WebDriverWait(driver, 10).until(ExpectedConditions.elementToBeClickable(By.xpath("//a[@class='english']"))).click();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.