【问题标题】:How to check for hyperlink through Selenium Webdriver?如何通过 Selenium Webdriver 检查超链接?
【发布时间】:2021-08-07 16:42:54
【问题描述】:

我在 Eclipse 上使用 Selenium Webdriver,我想访问忘记密码的超链接:

<p class="mt15 text-center fs-12 forgot-password-links"><a href="forgotpassword.htm" class="text-blue text-capitalize text-center">Forgot Password?</a></p>

我尝试过使用 linkText、partialLinkTest 以及 WebElement。到目前为止似乎没有任何效果。有什么建议?提前致谢!

【问题讨论】:

  • 您的装订语言是什么? linkTextpartialLinkText 遇到的错误是什么?
  • 你能分享你到目前为止的尝试吗?
  • @Then("^user clicks on Forgot Password$") public void user_clicks_on_Forgot_Password(String href) throws Throwable { WebElement openLinks = driver.findElement(By.xpath("//div[@class= 'form-container-left']")); for(int i = 1; i

标签: selenium hyperlink webdriver automated-tests cucumber


【解决方案1】:

根据您提供的 HTML,可以使用以下 XPath 定位该元素:

//a[@href='forgotpassword.htm']

或者如果你更喜欢 cssSelector

a[href='forgotpassword.htm']

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-02-02
    • 1970-01-01
    • 2016-12-28
    • 2013-10-04
    • 2019-02-15
    • 1970-01-01
    • 2017-03-23
    • 2013-12-21
    相关资源
    最近更新 更多