我使用phantomjs
版本1.1.0
和phantomjs-2.1.1.exe
为windows
。在phantomjs上找不到的元素但在铬上工作正常
这是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选择器,在我的情况下它工作正常。 –