Store the date of my posts knowing my username in the forum xpath following-sibling axes

@admin @Plankton @ulrich

Hi to all

From long time I search a solution to recognize element near other elements, after long researches I found some special xpath to do this it are xpath axes

https://www.w3schools.com/xml/xpath_axes.asp

I want to store my date post knowing my username in the forum how i can create a correct xpath to do this ?

Seems a simple scrape but I have not a fixed part to recognize the dates to store, I know my username, after i must store the date post.

Any suggestion please ?

I want to know these special xpath to detect element near others element

I added image

Thanks

Does no one in the forum know how to carry out such a command?

It is a command with data extraction based on an anchor, ui vision can carry out this type of automation ?

Is it technically possible to create a macro code with ui vision for this work ?

Thanks

What about

xpath=//*[@id="post_1"]/div/div[2]/div/div[2]/div/a/span
xpath=//*[@id="post_2"]/div/div[2]/div/div[2]/div/a/span

or relative xpath

//a[@class='post-date']//span[@class='relative-date']

This not solve the problem becase can not detect post of my username, this is a generic xpath

I need a solution to select post only of my username i can not know post number or id

I need before search my username, if i find my username i continue to store post date of my post.

After i search and found my username i need to store the post date, if the username is not correct do not store the post date.

On imacros i can create a macro using xpath R (relative to anchor in my case is username) in ui vision i do not find a solution.

Hmmm maybe something along the lines of:

PseudoCode

if
i//article[@id=‘post_1’]//a[contains(text(),‘newuserkantu’)]
is true then store the value of
xpath=//*[@id=“post_1”]/div/div[2]/div/div[2]/div/a/span

and then loop through post1, post2, etc

Yes i need a solution like PsuedoCode

I think must use this

https://www.w3schools.com/xml/xpath_axes.asp

following-sibling Selects all siblings after the current node

But i can not know this xpath type

You should be able to do this just using a bunch of if conditionals but I checked my selector finder ChroPath and I don’t see anything about xpath axes. Maybe you can make a feature request with them

Here there are some examples nut it’s hard to use this type of xpath.

This is really a tricky challenge. On other websites “sourceExtract” plus some Regex can work, but on modern websites like this “Discourse” forum, the page source code is a mess full of Javascript.

If I had to do it, I would go for relative extraction and screen scraping (OCRExtractRelative command).

However, if anyone has an XPath solution I would be interested in this, too :wink:

1 Like

With OCRExtractRelative how you solve ?

You create image of username but date time change always how can detect time that change periodically ?

With green and pink box can be solved ?

It’s very strange that ui vision have not a XpathExtractRelative, imacros have this and working well but ui vision not have a similar command.

ANy suggestion will be appreciated

I solved this hard work with following xpath after long tests and researches.

following xpath allow to store element relative others elements.

This is the xpath combination

xpath=((//a[@href='/u/newuserkantu'][contains(.,'newuserkantu')])[1]/following::span[@class='relative-date'])[1]

Need to study following and sibling to create similar xpaths but are very useful for storing in dynamic page