问题
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