For positioning page elements,xpath Is the most powerful way, It's stable and versatile. But whether it can be used well is another matter, If not, it's a hole. Not much nonsense, Enter the theme:




Pictured above, We need to position“_ Provincial company” Fold button at front,xpath How do you write it?? Obviously, Thereid='_easyui_tree_1' Not a very safe fixed value,tag
name It's even more outrageous. Probablyid='ltree' It's reliable, But I can'tid No needid( In addition to the login page), In factid It's a good positioning tool, But it's not used in many scenarios, Then cultivate and usexpath Our habits and abilities are very important, Let's write down this example:

Stepwise analysis:


1. Usexpath, Because it's about“_ Provincial company” Front fold, that“_ Provincial company” I can't get away with it, with“_ Provincial company” As a starting point,xpath=.//span[text()="_ Provincial company"]

2. Axis required, Foldour is a former brother,/preceding:siblind::span

3. Ahead of you2 Brothers? Ha-ha, from“_ Provincial company” Start counting up, We're looking for the top onespan, In the middle is the icon of the folder. Second brother:[2]

Combine:

xpath = .//span[text()="_ Provincial company"]/preceding-sibling::span[2]


Of course, it can also be directly located here“_ Provincial company” Father<div id="_easyui_tree_1" class="tree-node"
>, And then take the first one downspan Children:.//span[text()="_ Provincial company"]/parent::div/span[1]

Look at a group again.:




If you don't want to count, You can use it directlypreceding-sibling 了.

For the time being, New progress, Update at any time!