samedi 24 octobre 2020

Problem with clicking on youtube icon using selenium automation from google apps button in top right corner

public void test() {
    driver.get("https://google.com");
    driver.findElement(By.cssSelector("div.gb_Vf a.gb_D")).click(); //clicks google app button
    WebDriverWait wait = new WebDriverWait(driver,30);
    wait.until(ExpectedConditions.elementToBeClickable(By.xpath("(//ul[@jsname='k77Iif']/li/a)[4]")));
    WebElement elm = driver.findElement(By.xpath("(//ul[@jsname='k77Iif']/li/a)[4]")); //this locator is uniquely identiying youtube icon
    elm.click(); //it should click youtube icon, but code is unable to do this
}

I tried many locators, even though they are uniquely identifying youtube icon manually, but code is not working. Please help me solve it. Thank you.

Aucun commentaire:

Enregistrer un commentaire