RE: How to write Xpath for below html code

Hi All,

Below is the html code


<a href=”javascript:leftnavExpand(‘Menu_on_KT_1-003_1854_3’); javascript:leftnavExpand(‘Menu_off_KT_1-003_1854_3’); ” onmouseover=”moveObject(‘Event_KT_1-003_1854_3’, event); setImage(‘ExpandIcon_KT_1-003_1854_3′,’images/icon_expand.gif’);” onmouseout=”layersShowOrHide(‘hidden’,’Event_KT_1-003_1854_3′); setImage(‘ExpandIcon_KT_1-003_1854_3′,’images/icon_blank.gif’);” onclick=”layersShowOrHide(‘visible’,’Lock_all’); LockObject(‘Lock_KT_1-003_1854_3’,event); “><img src=”images/icon_NotStarted.gif” style=”position: relative; left: 7px;” border=”0″></a>

for above html code how can write xpath and value showing is dynamic
i.e  KT_1-003_1854_3 dynamic

Thanks in advance

VEERENDER Default Asked on October 9, 2018 in Katalon Studio.
Add Comment
1 Answers

<a /> is link tag, so you can customize your xpath

driver.findElement(By.xpath(“//input[@class=’ ‘]”)).sendKeys(” “);


use contains for standard method of writing xpath.


driver.findElement(By.xpath(“//input[contains(@name,’ ‘)]”)).sendKeys(” “);


if it is a link –> use click() method instead of sendkeys()

Default Answered on October 12, 2018.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.