1

I am looking for protractor plugin, which parses HTML page looking for a particular string and gives me element selector?

For example, parse html files, search for occurrences of a particular string and then generate the element & xpath expressions that locate the string within the html file. Is there a node module which can automate this? or help me achieve this?

I want to use this in my protractor tests.

Thanks in advance.

JeffC
  • 22,180
  • 5
  • 32
  • 55
user2439903
  • 1,277
  • 2
  • 34
  • 68

1 Answers1

1

Choosing a good selector for an element is not something you can easily automate.

Tools like Firebug can generate XPath expressions and CSS selectors for selected elements, but they are either absolute and start from the very root html element, or can usually be simplified or improved.

Making a selector and a good one requires knowledge about what the structure of a particular page, the uniqueness of element's attributes and strategic thinking (using things that have less chances to change over time). ids, classes and other data-oriented attributes are usually good choices to rely on.

Look into elementor package - it makes debugging locators easy and convenient.

Also see:

Community
  • 1
  • 1
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195