使用硒和黄瓜测试 java class

Testing java class using selenium and cucumber

用户应该能够select首选语言 网站的内容是否应使用以下网站以 selected 语言加载?

这是我当前的代码,我如何修改以匹配这种情况?

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 enabled element so to click() on the element you need to use for the elementToBeClickable() and you can use either of the following :

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