html - 单击带有 <href> 和 <a> 标签的按钮

标签 html ruby selenium safari automation

我正在尝试单击嵌套在标记和 中的“立即验证”按钮。我无法直接导航到 href 链接,因为每个链接每次都有不同的激活标记,这就是为什么我宁愿点击它。

PFB html enter image description here

<a href="http://click1.clickrouter.com/redirect?token=a2258079c24c4c50a56b6b1ffb75d6e2&amp;url=https%3A//sequoia-api-staging-write.ymedia.in/write/api/v1/contact/activate_account%3FtempSignupToken%3D9190c8f7-70e7-4b4f-a915-2d4498eb7c32" style="text-decoration: none ; color: white" target="_other" rel="nofollow">Verify Now</a>

有人可以帮我处理代码吗?我已经尝试了以下代码,但仍然没有帮助。不确定,缺少什么。

@Selenium_driver.find_element(:xpath, "//button[contains(text(), 'Verify Now')]")

@Selenium_driver.find_element(:css, ".Verify.Now").click

@Selenium_driver.find_element(:link_text, "Verify Now").click

此外,iframe 中该电子邮件正文的页面源代码如下:

<div class="col-lg-12 col-md-12 col-sm-12" style="height:800px;clear:both;margin-bottom: 20px;padding-bottom: 20px;">
                      <iframe id="publicshowmaildivcontent" width="100%" height="100%" style="border: 0;">
                          EMAIL BODY
                      </iframe>
                  </div>

最佳答案

您可以针对您的情况使用以下 xpath:

driver.findElement(By.xpath("//*[contains(text(),'Verify Now')]")).click();

希望对你有所帮助。

关于html - 单击带有 <href> 和 <a> 标签的按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44513945/

相关文章:

html - 幻想字体在ie中加载不同

ruby - 如何防止使用 gem v. 2.0 自动安装 gems 文档

ruby - pony 不向 gmail 地址发送电子邮件?

java - 在 Java 中使用 Selenium - 无法识别元素(表中)

javascript - 单击时在每个 tr 行上切换类

html - text-align 不将 2 位数字居中,但适用于单个数字

java - Selenium (Java): ordered list of webelements but with nested divs

python - 使用 Chromedriver 在另一台电脑上运行 pyinstaller

html - 我应该如何居中对齐 html 表单?

ruby-on-rails - Boolean Enum throws Action can't be blank for false value in Rails-Admin