Unable to find element with xpath within nested framesets



  • I'm using driver.findElement(By.xpath("//a[@title='A K T İ V A S Y O N']")); to locate the element given below in the screenshots but getting Unable to find element error.

    enter image description here enter image description here enter image description here enter image description here

    There are nested classes and frames also. how can I use switch method for nested frames?

    My last try is the following one; Screenshot's attached also.enter image description here

    driver.findElement(By.xpath("//frameset[@id='fset1']//frame[@name='ax']//frame[@name='menu']//div[@id='vodaMenuDiv']//li[@id='CCBmain']//li[@id='ccbabone']//li[@id='ccbcquery']//a[@title='A K T İ V A S Y O N']")).click();



  • Use below alternatives to locate the element-

    driver.findElement(By.xpath("//li[@id='ccbcquery']/a")).click();
    

    equivalent css selector is

    driver.findElement(By.cssSelector("li[id='ccbcquery']>a")).click();
    

    OR

    driver.findElement(By.cssSelector("li#ccbcquery>a")).click();
    

    Pointed to be noted

    1. Make sure element is not in frame if yes then switch into respective frame using driver.switchTo().frame(frameid/element); and then perform action

    2. Use implicit/explicit wait to get element proper load and available in DOM

      driver.get("web_irl");
      driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
      

      Explicit Wait :

      new WebDriverWait(driver, 30).until(ExpectedConditions.visibilityOf(driver.findElement(By.cssSelector("li#ccbcquery>a")))).click();
      


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2