noellarkin
Senior Member
- Mar 14, 2021
- 1,006
- 1,492
Do you have a hierarchy for the order in which you try automating the above?
For me, its id and name first - - I'll always check if I can directly set the value of the field. This doesn't work with a lot of sites that have form field validation, but works for older sites.
In some cases, for buttons, I'll use select element by class, if it's the only button on the page.
These seem to work as long as the page doesn't have any complex javascript.
Reliability seems to go downhill from there: Relative XPath, absolute XPath and CSS Selectors. I'll try for Rel.XPath first, so I don't have to deal with that huge string of divs that comes with absXPath, but sometimes I won't really have much of an option.
I haven't needed to work with CSS selectors often, because absXPath usually gets me the required field even if RelXPath doesn't.
Would love to hear if any of you follow similar or different checklists. Also would love recommendations regarding how to extract better XPaths.
For me, its id and name first - - I'll always check if I can directly set the value of the field. This doesn't work with a lot of sites that have form field validation, but works for older sites.
In some cases, for buttons, I'll use select element by class, if it's the only button on the page.
These seem to work as long as the page doesn't have any complex javascript.
Reliability seems to go downhill from there: Relative XPath, absolute XPath and CSS Selectors. I'll try for Rel.XPath first, so I don't have to deal with that huge string of divs that comes with absXPath, but sometimes I won't really have much of an option.
I haven't needed to work with CSS selectors often, because absXPath usually gets me the required field even if RelXPath doesn't.
Would love to hear if any of you follow similar or different checklists. Also would love recommendations regarding how to extract better XPaths.