Home > Mobile >  Unable to click on "know more..." link on the page given below using the selenium webdrive
Unable to click on "know more..." link on the page given below using the selenium webdrive

Time:01-14

page url: enter image description here

CodePudding user response:

You were almost there but the locator strategy for the link Know More... was slightly off as there are multiple elements with almost similar attributes:

2elements


Solution

You can use either of the following locator strategies:

  • Using partialLinkText:

    WebElement frame = DriverManager.getDriver().findElement(By.cssSelector("frame[name='login_page']"));
    DriverManager.getDriver().switchTo().frame(frame);
    DriverManager.getDriver().findElement(By.partialLinkText("More...")).click();
    
  • Using cssSelector:

    WebElement frame = DriverManager.getDriver().findElement(By.cssSelector("frame[name='login_page']"));
    DriverManager.getDriver().switchTo().frame(frame);
    DriverManager.getDriver().findElement(By.xpath("div#welcomesec1 span.lightbluecolor > a")).click();
    
  • Using xpath:

    WebElement frame = DriverManager.getDriver().findElement(By.xpath("//frame[@name='login_page']"));
    DriverManager.getDriver().switchTo().frame(frame);
    DriverManager.getDriver().findElement(By.xpath("//div[@id='welcomesec1']//span[starts-with(., 'Your security is of utmost')]//following::span/a[starts-with(., 'Know') and contains(., 'More...')]")).click();
    
  • Related