【发布时间】:2016-11-23 13:16:40
【问题描述】:
我使用phantomjs 版本1.1.0 和phantomjs-2.1.1.exe 为windows。
这是 HTML 代码
<div class="right-align" style="display: inline-block; vertical-align: middle; border-radius: 6px; margin-left: 20px; flex-grow: 100;">
<div>
<a class="t-next-pd continue-to-query button-text" style="background-color: rgb(11, 197, 216); color: rgb(255, 255, 255); height: 40px; padding: 0px 16px; text-decoration: none; display: inline-flex; font-weight: 500; font-size: 16px; border-radius: 4px; z-index: 100; cursor: pointer; align-items: center; justify-content: center; border: 1px solid rgb(11, 197, 216); width: 100%;">
<span style="display: inline-block;">CONTINUE</span>
</a>
</div>
</div>
我尝试使用
来定位元素- 两个类的相对 xpath:
.//*[@class='t-next-pd continue-to-query button-text'],.//*[@class='right-align'] - 文字
- 部分文字
- 通过链接
- 通过 cssSelector
- 带文本的相对 xpath
- 通过绝对 xpath(最后优先级)
- 按类名
- javascript 执行器
- 隐式等待和显式等待
似乎没有任何效果
只有当我输入姓名和年龄时,CONTINUE 按钮才会被激活。 这是CONTINUE按钮未激活时的代码。
<div class="right-align" style="display: inline-block; vertical-align: middle; border-radius: 6px; margin-left: 20px; flex-grow: 100;">
<div>
<a class="button-text" disabled="" style="background-color: rgb(199, 199, 199); color: rgb(255, 255, 255); height: 40px; padding: 0px 16px; display: inline-flex; text-decoration: none; font-weight: 500; font-size: 16px; border-radius: 4px; z-index: 100; cursor: pointer; align-items: center; justify-content: center; width: 100%;">
<span style="display: inline-block;">CONTINUE</span>
</a>
</div>
</div>
【问题讨论】:
-
我在激活按钮上使用了这个
a.t-next-pd.continue-to-query.button-text。这是一个 CSS 选择器,在我的情况下可以正常工作。
标签: selenium automation phantomjs headless-browser