Unable to automate span class in Selenium

29 views
Skip to first unread message

Steffi

unread,
Jul 21, 2016, 6:07:22 AM7/21/16
to Selenium Users
 Hi,

I am trying to automate icon "timelog"  the HTML code is

<a class="quickLinks" onclick="toNavUrl('f3987c7b3583d8e1e74b0ea4de589863');return false;" href="javascript:void(0);">
<h2 class="sti-item" data-type="mText">TIMELOG</h2>
<h3 class="sti-item" data-type="sText"></h3>
<span class="sti-icon sti-icon-timelog sti-item" data-type="icon"></span>
</a>

I have tried following

driver.findElement (By.partialLinkText("timelog")).click();

driver.findElement(By.cssSelector("span.sti-icon sti-icon-timelog sti-item")).click();

driver.findElement(By.xpath("//span[@class = 'sti-icon sti-icon-timelog sti-item']")).click();


but getting error - unable to locate element.


can anybody help me?


Steffi.

Praveen iG

unread,
Jul 21, 2016, 8:06:34 AM7/21/16
to Selenium Users

Hello,
Assuming these xpaths point to an unique element,

driver.findElement (By.partialLinkText("timelog")).click();
I think this should be TIMELOG instead of timelog?

driver.findElement(By.cssSelector("span.sti-icon sti-icon-timelog sti-item")).click();

This one is wrong because classes need to be separated by a dot character.
Use span.sti-icon.sti-icon-timelog.sti-item

driver.findElement(By.xpath("//span[@class = 'sti-icon sti-icon-timelog sti-item']")).click();

This is wrong syntax.  It should be  //span[contains(@class,'classname1' and contains(@class, 'classname2')]

Regards,
Praveen


--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/b5ba9d79-b509-42f2-be56-d96131eaf774%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages