How do I get dynamic button id as text with partial match?


#1

When using verifyElementPresent, I get True return value.
But when I try to extract the id as text using the following code, it shows the following in the Log =>

  • [info] Executing: | sourceExtract | xpath=//*[contains(@id, “10.30-13.00”)] | match1 |

  • [error] Missing * or REGEX in sourceExtract. Extracting a plain text doesn’t make much sense

I need to know the correct code to extract the id by partial match from the page source code.
I need to get as text by eliminating this part "10.30-13.00” of the dynamic id; remainder will be something like 55 or 36, a number.

I am stuck at this for over 2 months. Please help and please explain, I am NOT an expert. :slight_smile:


#2

Can you post a link to the website? Or at least a HTML code snippet?


#3

The problem is that the page gives access to the radio button for two minutes tops. at 01:00:00 and then it does not load the page with the radio button (our target with the dynamic / changing id). It shows an overlapping message.

The id starts with something like this : id=10.30-13.0050 and when users have clicked and booked, it reduces the last two digits of the id by 1 until it reaches 0 or 00 (I don’t know). So the part “10.30-13.00” remains constant.

When I recorded each step, the clicking of the radio button was captured in Kantu code as follows, in the form of two commands :

COMMAND : type
TARGET : id=10.30-13.0050
VALUE : 50

COMMAND : CLICK
TARGET : id=10.30-13.0050

Should I save the page as html single file and then post it?


#4

Actually, I should have asked first: Why do you need the button ID? Just to click on it, or do you need the ID for something else?


#5

Just using click or ckickAndWait or even XClick along with partial match using XPATH, it does not work.

As shown in the recorded steps, I think the appended number of slots free (the number starting at 80 or 50 and then decreasing by one for every customer) is to be entered as VALUE with type COMMAND.
I think I have to BOTH type and click the radio button in terms of Kantu code.
The website has made it a bit difficult to prevent automation.

I am not even sure my XPATH expression or partial match finder code is correct.

I can give you any code that I am using so that you can check whether it’s okay or not.

And I’m posting the HTML file that I saved just now : https://drive.google.com/open?id=18crhW-vuyMIOV2k5XRGPTqY_wJaX2ecP

There are two separate folders, one with the complete set of files and the other as a single html file, download whichever you may need.

I just found this in the elements :

<td><input type="radio" name="timeForDisp" id="10.30-13.000" value="0" disabled="disabled" onclick="enablebookslotbtn(this.id)"><label for="10.30-13.000">0</label>
&nbsp;</td>

#6

Thanks. Can you also post a website screenshot and mark the element to be clicked? (So I know I am looking at the right place)


#7

Sure, I will do it today after the web page is accessible again.


#8

I have added a folder “Screenshots” with unedited and edited screenshots. Please view them by following the previously posted link.


#9

Any solution yet guys?


#10

I am really lost on what you want to do. Do you need to extract the ID?

Anyhow, If you want to use partial text match on an element’s ID I would recommend CSS selectors. Much more reliable than Xpath imo.

{
  "Command": "click",
  "Target": "css=[id*=10.30-13.00]",
  "Value": ""
},

This will find and click any element that contains an ID with the string 10.30-13.00.

So, if you have either <td id="10.30-13.0050"></td> or <td id="5010.30-13.00"></td> or <td id="10.30-13.00"></td> it will find it.


#11

Thanks for the new approach brother. I really do.
How do I solve the first problem where I am supposed to TYPE the last two digits of the id as VALUE into the TARGET?

When I recorded each step, the clicking of the radio button was captured in Kantu code as follows, in the form of two commands :

COMMAND : type
TARGET : id=10.30-13.0050
VALUE : 50

COMMAND : CLICK
TARGET : id=10.30-13.0050


#12

I tried your code today, it’s not working.

Even xpath=//*[contains(@id, “10.30-13.00”)] does not work.


#13

We are working in the dark here. I need the website or html snippet to test and provide answer with accuracy.


#14

I understand.

https://drive.google.com/open?id=18crhW-vuyMIOV2k5XRGPTqY_wJaX2ecP

I have uploaded some stuff which may help. And this is the snippet which I could extract from the page source in Developer mode of Google Chrome browser :

<td><input type="radio" name="timeForDisp" id="10.30-13.000" value="0" disabled="disabled" onclick="enablebookslotbtn(this.id)"><label for="10.30-13.000">0</label> &nbsp;</td>


#15

Testing with that snippet it works. Try adding quotes.

{
  "Command": "click",
  "Target": "css=[id*='10.30-13.00']",
  "Value": ""
}

Try adding single quotes around the number, like in the code above.


#16

The website allows slot booking only at 01:00 A.M. After that, the page is accessible but with an overlaying message, covering and disabling the link on the calendar through which we would get the radio button in question.

I’ll try your quoted code today, will let you know, thanks bro. :slight_smile:


#17

Hurrah!!! It works after adding the quotes. Thanks @Diego_Fortes

Thanks a lot!!!


#18

I will be able to put it to test after a few days when slots are available on the website, I will let you know how it goes.


#19

Nope, it still fails bros.
LOG =

  • [info]

Executing: | click | css=(id*=‘10.30-13.00’] | |

  • [error]

timeout reached when looking for element ‘css=(id*=‘10.30-13.00’]’