Search code examples
seleniumxpathidekatalon-recorderkantu

Find xpath in html element using a part of href only katalon recorder, kantu, selenium ide, ui vision


I need to detect via xpath an element (image with href) but i know a part of href only

This is the html

<a href="/play.php?video=123456">
<div class="video-splash" data-src="https://myimge-555888.jpg?md5=dfgdfsdgsowVf0QnDcAg&amp;expires=16018841600&amp;origin=103&amp;mid=0df2fd8d-85b1-47da-a371-489a7328ffb4">
<div class="video-time"><i class="fas fa-play"></i> <b>HD</b> 43:25</div>
</div>
</a>

I know the video 123456 (part of href)

video number change periodically

data-src change periodically

I tried these xpaths but in this case do not work

xpath=//a[contains(@href, "123456")]

xpath=//a[ends-with(@href, '123456')]/img

xpath=//a[contains(@href, '123456')]/img

How can i detect the element using a part of href only ?

I need a xpath only that can detect the element please.

Need a generic xpath because some attributes are dynamic video=??? and data-src=??? and <b>???</b> ??? </div>

??? dynamic values that change always, i need to detect it via video number.

I add more html code

<div>

<h2 class="page-h2">
Performer <b>username</b> — Recent Recordings
</h2>
<div class="video-thumb">
<a href="/play.php?video=550420">
<div class="video-splash" data-src="https://v02.frontgross.com/username/2020-04-25,29-59.jpg?md5=BV75Ney9jydwiZgdITkjSg&expires=2705442700&origin=205&mid=5e5c77ca-f750-49ed-9527-725754b972f2">
<div class="video-time"><i class="fas fa-play"></i> <b>HD</b> 59:25</div>
</div>
</a>
<div class="video-info">
<div>
<a href="/?performer=username"><b>username</b></a>
</div>
<div class="video-info-sub"><span class="video-views">22.5K views</span> • 2020-04-25 29:59</div>
</div>
</div>
<div class="video-thumb">
<a href="/play.php?video=529055">
<div class="video-splash" data-src="https://v02.frontgross.com/username/2020-04-25,02-00.jpg?md5=d2GDbtiHuKT-by9A9qcMIA&expires=2705442700&origin=205&mid=5e5c77ca-f750-49ed-9527-725754b972f2">
<div class="video-time"><i class="fas fa-play"></i> <b>HD</b> 45:25</div>
</div>
</a>
<div class="video-info">
<div>
<a href="/?performer=username"><b>username</b></a>
</div>
<div class="video-info-sub"><span class="video-views">20.0K views</span> • 2020-04-25 02:00</div>
</div>
</div>
<div class="video-thumb">
<a href="/play.php?video=529725">
<div class="video-splash" data-src="https://v02.frontgross.com/username/2020-04-24,29-55.jpg?md5=RrwtygDUT_zxTPf4mC2KAw&expires=2705442700&origin=205&mid=5e5c77ca-f750-49ed-9527-725754b972f2">
<div class="video-time"><i class="fas fa-play"></i> <b>HD</b> 2:02:29</div>
</div>
</a>
<div class="video-info">
<div>
<a href="/?performer=username"><b>username</b></a>
</div>
<div class="video-info-sub"><span class="video-views">20.9K views</span> • 2020-04-24 29:55</div>
</div>
</div>
<div class="video-thumb">
<a href="/play.php?video=527092">
<div class="video-splash" data-src="https://v02.frontgross.com/username/2020-04-25,22-00.jpg?md5=unQIgoVWLXy5cBH4sPVWUw&expires=2705442700&origin=205&mid=5e5c77ca-f750-49ed-9527-725754b972f2">
<div class="video-time"><i class="fas fa-play"></i> <b>HD</b> 20:52</div>
</div>
</a>

Solution

  • This is the solution

    xpath=//div/a[@href='/play.php?video=123456']
    

    Need to start xpath with //div/a

    Other solutions do not works.