Is there a name for the concept of automatically generating (potentially with machine learning?) selectors? I feel like I’ve seen similar projects come across HN, but I’m at a loss for what to search for.
Robula+: an algorithm to generate robust XPath-based locators
11–16 of 16 posts
Re: Robula+: an algorithm to generate robust XPath-based locators
#12Earlier quoted context omitted.
It depends on the content of the HTML document but I agree with you. I tried running the algorithm in Chrome. It output much shorter XPath than one copied from Chrome Developer tool. e.g. "//*[@id="rso"]/div[4]/div/div[1]/a/h3" => "//*[contains(text(),'(text of the element)')]"
Your example seems pretty awful though. You'd rarely want to select element based on it's text
Re: Robula+: an algorithm to generate robust XPath-based locators
#13Let's look at some of the Robula test cases:
Input:
Task: get the true element, XPath:
//*[@class='true']
Pattern matching: {.}
Input:
Get XPath:
//*[@class='true' and @title='foo']
Pattern matching: {.}
As you see, you do not need a new syntax for attributes. Input and pattern are the same!Input:
Get the third element.XPath:
//*[3]
Pattern matching: {.}
Input:
Get the h1 in the divXPath:
//div/*
Pattern matching: {.}
This last example is actually getting to the point of pattern matching. Because every part of the patterns must match. If the div is missing, it will report, "div not found". If the h1 is missing in the div, it will report "h1 not found". But the XPath will just report "found these elements" or "found nothing".Re: Robula+: an algorithm to generate robust XPath-based locators
#14Is there a name for the concept of automatically generating (potentially with machine learning?) selectors? I feel like I’ve seen similar projects come across HN, but I’m at a loss for what to search for.
It's not that easy to reuse those because projects often differ in what they need (do you really want unique selectors for one single element?). But there are a couple of CSS selector generators, maybe you are referring to something like https://github.com/fczbkk/css-selector-generator or https://github.com/antonmedv/finder ?
Re: Robula+: an algorithm to generate robust XPath-based locators
#15Earlier quoted context omitted.
It's not that easy to reuse those because projects often differ in what they need (do you really want unique selectors for one single element?). But there are a couple of CSS selector generators, maybe you are referring to something like https://github.com/fczbkk/css-selector-generator or https://github.com/antonmedv/finder ?
I made a greasemonkey script for this purpose. Create XPath, CSS or pattern matching. Unfortunately it stopped working when Firefox got its new API. But here is a video of it: https://youtu.be/PUrBJ6wOXvE?t=50
Re: Robula+: an algorithm to generate robust XPath-based locators
#16Is there a name for the concept of automatically generating (potentially with machine learning?) selectors? I feel like I’ve seen similar projects come across HN, but I’m at a loss for what to search for.