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

4
  • 1
    Which language are you trying to click on first, second or English? Commented Jul 16, 2020 at 22:17
  • English first... Commented Jul 16, 2020 at 22:28
  • 1
    You want to click on English, that's your scenario, right? Commented Jul 16, 2020 at 22:29
  • yes............. Commented Jul 16, 2020 at 22:32

1 Answer 1

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();
    
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.