【问题标题】:Selenium By.xpath, By.linkName worked before, now it's not working anymore [closed]Selenium By.xpath,By.linkName 以前工作过,现在它不再工作了[关闭]
【发布时间】:2014-05-18 04:46:36
【问题描述】:

这是我试图点击链接的 html 代码:

class="MainMenuBody" valign="top">

        <a href="https://portal.regify.com/phpCreateRegify.php">Create regimail online</a><br>

这里是代码:

driver.findElement(By.xpath("//a[contains(@href, 'phpCreateRegify.php')]")).click();

我也尝试过使用此driver.findElement(By.linkText("Create regimail online")).click(); 和部分链接文本,甚至尝试过driver.switchTo().defaultContent();,但似乎没有任何效果。几周前它起作用了,但知道它没有。还有其他想法、建议吗?

【问题讨论】:

    标签: java html selenium xpath web


    【解决方案1】:

    您是否检查过您的 Webdriver 是否仍在该元素所在的正确页面上?

    我曾经遇到过类似的问题,由于网站的变化,我正在寻找的元素被移动到另一个网站,我不得不调整我的代码。

    因此尝试逐步导航到该元素所在的站点。 为我工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-07-05
      • 2015-06-29
      • 1970-01-01
      • 2021-12-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多