1

enter image description hereuser should be able to select the preferred language and content of the web site should be loaded with the selected language using followng web site?

This is my current code how I Modify to match this scenario?

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

Shalitha Jayamal
  • 171
  • 2
  • 16

1 Answers1

1

The element is a JavaScript enabled element so to click() on the element you need to use WebDriverWait for the elementToBeClickable() and you can use either of the following Locator Strategies:

  • 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();
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352