How to get the xpath for the span button

血红的双手。 提交于 2019-12-25 18:57:36

问题


I am new to selenium IDE and trying to get the target in the right order. I have tried many combination to get the right element when there is span for the button. I need to get the xpath for the "Read More" button.Can someone please advise how the target in the IDE should be. Here is the code:

<div class="is_centered l_bottom_pad">
<a class="btn_teal_outline has_arrow" href="https://test.com/jobs/view.php?id=8">
<span>Read More</span>
</a>
</div>

回答1:


In some browsers (I think it was mainly MSIE) it is necessary to address the <a> element, not its child <span> in order to click a button or link. So you should adress:

//a[span[text()='Read More']]

Or you go directly for LinkText ("Read More") instead of XPath!




回答2:


Targeting for span button is very simple. Just see what is unique attribute in that element. I feel the button text itself is unique.Try this one

xpath=.//span[text()='Read More']


来源:https://stackoverflow.com/questions/35796732/how-to-get-the-xpath-for-the-span-button

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!