I have an issue recognizing the exact text match with XClickText. As I have some very similar lines I need an exact text match.
Here is what XClickText finds with the given search strings in below website:
-) “Aktionskurs -20% Guten Morgen Yoga - 13.01.-24.02. (7 Wochen) STUDIO” > I need to find this string but it finds nothing
-) “Aktionskurs -20% Guten Morgen Yoga” > finds a text but is not sufficiently identifying the line.
I tried to replace “.” and “-” with “?” but it does not work. How can I solve this?
ORC commands and any command with X like XClick are extremely unreliable and slow commands. I would always stay away from those.
There should be a way to identify the locator. Can you post the html code of that portion you try to locate? I’m also not sure what you mean identify the locator.
Get Value of a specific Tag Attribute:
…
< th scope=“row” >
< a href=“/003A000000qaIZ7?srPos=0&srKp=003”
data-seclke=“Contact”
data-seclkh=“804d175c78930e8ffe5889584a57d259”
data-seclki=“003A000000qaIZ7”
data-seclkp=“/003A000000qaIZ7”
data-seclkr=“1”
onmousedown=“searchResultClick.mousedown(this, event)”>Berta Abramovich< /a>
< /th>
Hi @noahhath ,
I fully agree that OCR/XClick ist unreliable. I need to find one of the following texts and then click on it. For example the two marked lines have following locators:
Instead of using any xpath=(//*[@id… use the tag where that id is imbedded for example if it is < td> so you haver a more accurate targeting in case there are other tags with the same ID
xpath=(//td[@id=“filter-event-products”])…
If you need to click on each of them:
1.Count the tags
{
“Command”: “storeXpathCount”,
“Target”: “xpath=(//td[@id=“filter-event-products”]))”,
“Value”: “myNbrOfRows”,
}
Click on them on by one using the times command
You want to target the following tags like first, second, third
xpath=(//[@id=“filter-event-products”])[1]
xpath=(//[@id=“filter-event-products”])[2]
xpath=(//*[@id=“filter-event-products”])[3]
using
times myNbrOfRows
click xpath=(//td[@id=“filter-event-products”])[{!time}]
end
Hi @noahhath ,
its clear how to click on the lines as you described using the line number:
The problem is that I don’t know the line number to click on. Therefore I have to read the text upfront (the content is dynamic), e.g. “Aktionskurs -20% Guten Morgen Yoga - 06.05.-24.06. (7 Wochen) STUDIO”, then identify the corresponding line number and then trigger click xpath=//*[@id=“filter-event-products”]/div[2]/div/div[2]/div[2]/table/tbody/tr[37]/td[2].
So I need to read the text and identify the corresponding line number/locator/xpath.
Hi, unfortunately I can not run kantu scripts on html pages stored on the hard drive so I could not test the current script but this might give you some hints:
This is the HTML code you have to look at. It’s shows up as often as you have check boxes to click:
Find out how many checkboxes we have to click by counting the occurrence of the exact word “Aktionskurse” in the TD tag < td >Aktionskurse< /td>: xpath=(//td[text()=‘Aktionskurs’])
For each occurrence click the checkbox. Identify the textbox by the following criteria:
a. its’ a < input> tag
b. that input tag holds a data-selector that starts with the word “event-activity”
c. That input tag also has a type=“checkbox”
d. That input tag also has a class=“select-item select-single”
→ xpath=(//input[starts-with(@data-selector,‘event-activity’) and @type=‘checkbox’ and @class=‘select-item select-single’])[1]
That should point to the first instance of the checkbox
To point to the second checkbox instance you have to increase the index
→ xpath=(//input[starts-with(@data-selector,‘event-activity’) and @type=‘checkbox’ and @class=‘select-item select-single’])[2]
You do that in a “times” loop. So the code would look something like that. I could not really test it but should be close to what you need.
Hi @noahhath , I had a look at your proposed solution. Not sure if I understood it correctly.
I need to click only one specific occurency of the entries not all of them, e.g. only “Aktionskurs -20% Guten Morgen Yoga - 06.05.-24.06. (7 Wochen) STUDIO”. So how do I know for the “click” command the “x”: “xpath=//*[@id=“filter-event-products”]/div[2]/div/div[2]/div[2]/table/tbody/tr[$x ]/td/div”?
The solution I worked with up to now is to loop through the items:
“xpath=//*[@id=“filter-event-products”]/div[2]/div/div[2]/div[2]/table/tbody/tr[$times]/td/div” and to extract the corresponding text value via “storeText” and compare it to the text I search for, e.g. “Aktionskurs -20% Guten Morgen Yoga - 06.05.-24.06. (7 Wochen) STUDIO”.
But this solution is too slow. I takes alot of time to loop through all the element. I have pages with more than 100 elements and in order to find several text elements it all takes too much time and is additionally not stable enough. So I was searching for a method where I can do it the other way round. Instead of looping through the locators and reading the text > search for the text and derive the locator.
ok, so then what is your identifier to click it? How from the human point of view do you decide which one to click? Is it always the first one to click from the list or the one that always says “Aktionskurs -20% Guten Morgen Yoga - 06.05.-24.06. (7 Wochen) STUDIO”?