Add a relative command to detect relative element

Hi @admin

I used from long time imacros and it have a wonderful command the relative click position, most better of relative click of ui vision that work with images.

On imacros you detect an element and with R (right of element) or -R (left of element) you click relative element, this is the best command i found in automation software and in ui vision missing.

Ui vision Relative Clicks with green and pink boxes is very bad and slow, imacros click relative is better works well and fast

I suggest you to create a command to create an anchor and next command is relative to anchor to easy detect element hard to detect like imacros.

On imacros is very easy to detect every element in fast time this is an example

TAG POS=1 TYPE=B ATTR=TXT:Land
TAG POS=R1 TYPE=TXT ATTR=CLASS:code&&TXT:* EXTRACT=TXT

First line is a simple Click
Second line is the element at right of the element (R1) in first line and it will be detect in automatically.

Can you add a similar command in ui vision ?

Thanks

Interesting. Do you have a few example links/pages where the relative positioning helps you to find elements and scrape data more reliably? We could use this to test.

Hi thanks for reply

Usually i use relative tag click to detect some element in table to skip column and choice some lines.

Example:

http://www.freeproxylists.net/

If i need to save all uptime of Los Angeles what solution i can use with ui vision ?

With imacros relative tag i make a simple click on Los Angeles Text (similar ui vision xpath=//td[contains(.,‘Los Angeles’)])[1] and after with TAG POS R1 i click and store the first value at right of my anchor using wildcard * like text to search (R1 detect the position do not need a text) if i need the second value i use TAG POS R2 (using Los angeles like anchor).

With ui vision is not easy store only some column with prefered values

I add an image to show relative tag with relative tag is easy to click and store every value in every line and colums starting from an anchor, with ui vision is very hard to do this work.

It’s simple to click and store multi line with some conditions (example Los Angeles and Edmond) too using more anchors and detecting value to store using relative click R-n or Rn (n = number).

Thanks for the details. The iMacros “Relative positioning” is a clever method. And it was really good when iMacros was invented. But meanwhile XPath can be used to do almost the same. (If you find an example or use case that can not be done with XPath, please let me know!)

If i need to save all uptime of Los Angeles what solution i can use with ui vision?

You almost had the solution :slight_smile: You can use the XPath CONTAINS selector to search for a parent element with a given text (as you did) and then use /td[X] to select the table column that you need. So for the first column (here to extract the IP address) it is /td[1]. This screenshot shows what I mean:

We use XPath Contains to search for the row that has the word “US” and then scrape the other cells in this row, e. g. the IP address:

My test macro is below. In it I use click for quicker testing. To actually extract the value just replace it with the storeText web scraping command.

{
  "Name": "xpathcontains",
  "CreationDate": "2020-6-1",
  "Commands": [
    {
      "Command": "open",
      "Target": "https://free-proxy-list.net/",
      "Value": ""
    },
    {
      "Command": "comment",
      "Target": "Locator as recorded",
      "Value": ""
    },
    {
      "Command": "click",
      "Target": "xpath=//*[@id=\"proxylisttable\"]/tbody/tr[1]/td[1]",
      "Value": ""
    },
    {
      "Command": "click",
      "Target": "xpath=//*[@id=\"proxylisttable\"]/tbody/tr[2]/td[3]",
      "Value": ""
    },
    {
      "Command": "click",
      "Target": "xpath=//*[@id=\"proxylisttable\"]/tbody/tr[1]/td[3]",
      "Value": ""
    },
    {
      "Command": "click",
      "Target": "xpath=//*[@id=\"proxylisttable\"]/tbody/tr[2]/td[1]",
      "Value": ""
    },
    {
      "Command": "comment",
      "Target": "New locator with CONTAINS",
      "Value": ""
    },
    {
      "Command": "click",
      "Target": "xpath=//*[contains(.,\"US\")][1]/td[1]",
      "Value": ""
    },
    {
      "Command": "click",
      "Target": "xpath=//*[contains(.,\"US\")][1]/td[3]",
      "Value": ""
    },
    {
      "Command": "click",
      "Target": "xpath=//*[contains(.,\"US\")][2]/td[1]",
      "Value": ""
    },
    {
      "Command": "click",
      "Target": "xpath=//*[contains(.,\"US\")][2]/td[3]",
      "Value": ""
    }
  ]
}

PS: I also tested with http://www.freeproxylists.net/ from your example and (only) there I have the very strange problem can I can never select the first match for a given Xpath contains. Very strange. But on all other tables that I tested the above XPath contains locator strategy works well.

3 Likes

Thanks admin for the example is a new command that I do not know and I would like to try it a few days in various tables to understand if I can extract data from any column.

Thank you, I’ll rewrite you in a few days, after trying the code in various tables to see if I can extract from all the tables and columns.

I tried this and works like a charm is very good :slight_smile:

It solved my problem to store dynamic value from the tables many thanks

With this method is easy to store from table prefered columns and lines

1 Like

if XPah has a lot ‘US’. example: US1 US2 US3. How can I pick exactly US2

@nvt512 XPath can also be instructed to select the n-th occurrence of an element, e. g. the 3rd time US is found.