1

I am having some trouble clicking a menu button on a webpage for work. The error occurs whether I am using Selenium or Cypress. While using cypress I get an uncaught exception error, and an error stating the (html) document cannot be read - while using selenium the element cannot be found.

After I login to the application I can't access anything.

driver.switchTo().defaultContent();
driver.switchTo().frame(driver.findElement(By.tagName("frameset")).findElements(By.tagName("frame")).get(1));
driver.findElement(By.cssSelector("body > table.section > tbody > tr > td > table > tbody > tr > td:nth-child(1)")).click();

I have tried to find it using the xpath as well. I'll also provide a snip of the html. Any help or guidance would be greatly appreciated.

HTML Example

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352

1 Answers1

0

To click on the <td> element you need to switchTo() the ignoring the using either of the following locator strategies:

  • Using cssSelector:

    driver.switchTo().defaultContent();
    driver.switchTo().frame(driver.findElement(By.cssSelector("frame#1[src^='displayMenu']")));
    driver.findElement(By.cssSelector("table.menubutton > tr > td")).click();
    
  • Using xpath:

    driver.switchTo().defaultContent();
    driver.switchTo().frame(driver.findElement(By.xpath("//frame[@id='1' and starts-with(@src, 'displayMenu')]")));
    driver.findElement(By.xpath("table[@class='menubutton']//tr/td")).click();
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352