K
K
ksvdon2014-06-10 00:19:12
selenium
ksvdon, 2014-06-10 00:19:12

Finding elements in Selenium

There is no ID or Name in the area of ​​the link I'm interested in. I was thinking of doing an XPath search (typing the full href="and/full/record"). But it turned out that there is a dynamic part (numbers) in href and this will not work (maybe you can put some kind of asterisks or something like that in the place where changing values ​​\u200b\u200b- but I don’t know). I tried to do an XPath search by title, but I can't see it that way... It didn't work out. I decided to do a search by find_element_by_partial_link_text - it also produces some errors. How to find (prescribe) the desired element in such a situation? I'm barely familiar with all of this. Here is an example:

<li class="pageIcon">
    <a href="/cpsess3185677916/scripts/command?PFILE=Server_Status" title="Server Status" >
        <img src="/cPanel_magic_revision_1399286476/themes/x/icons/serverstatus_v2.gif" alt="Server Status" />
        <span>Server Status</span>
    </a>
</li>

click href...

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
maxaon, 2014-06-10
@ksvdon

Why didn't xpath contains fit?
for example
//a[contains(@href,'command?PFILE=Server_Status')]

I
inmarko, 2014-08-22
@inmarko

imho, xpath is a very bad option to look for. Add id for elements, it will be easier. Or, use css selectors to find
driver.findElement(webdriver.By.css(".pageIcon > a"));
something like this

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question