webdriver中定位元素,报无法找到元素的问题时,需要查看以下几点:

1 用火狐的firebug插件定位元素,确保这个元素的定位正确;

2 在火狐的firebug插件的,在html页签中输入frame或者iframe去查看这个元素所在的frame或iframe是什么;

写如下语句:

WebElement iframe = driver.findElement(By
    .xpath("//*[@id='ContentFrame']"));
  driver.switchTo().frame(iframe);

webdriver中定位元素,报无法找到元素的问题

3 这个页面的元素用完后,需要写下如下语句:

driver.switchTo().defaultContent(); 

相关文章:

  • 2021-06-16
  • 2021-09-15
  • 2021-09-26
  • 2021-12-05
  • 2021-08-02
  • 2021-08-19
  • 2021-07-31
猜你喜欢
  • 2021-10-28
  • 2021-05-29
  • 2021-06-27
  • 2021-08-29
  • 2021-08-24
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案