Reputation: 104
The page i want to interact with contains:
<a class="qwe" onclick="abc;">
I cannot find a way to click that object using selenium.
Tried:
By.XPath("/a[contains(text(),'qwe')]"
and
By.ClassName("qwe")
It doesn't find anything.
<div class="page-characterselect">
<div class="charselect">
<div><ul><li>
<a class="Player_Controller" onclick="client.characterSelect('XYZ@ABC');">
<h4 class="char-list-name">XYZ</h4>
<h5 class="char-list-level">Level <span>24</span></h5>
<h5 class="char-list-class">Control Wizard</h5>
<h5 class="char-list-race">Sun Elf</h5>
</a>
</li></ul></div>
</div>
</div>
Upvotes: 0
Views: 329
Reputation: 32855
By.XPath("/a[contains(text(),'qwe')]"
is wrong XPath, because it starts from current node and looks for link text equals "qwe", but what you want is class name.
You should have posted your HTML from the beginning. Here are my suggestions.
By.XPath(".//div[@class='charselect']//a[@class='Player_Controller']");
By.CssSelector(".charselect .Player_Controller");
If there are other links with class Player_Controller
, then you need post more <li>
to see what are the differences between those.
Upvotes: 1