M
M
mmm19192019-09-12 15:22:57
HTML
mmm1919, 2019-09-12 15:22:57

How to create simple XPATH? As short as possible and working, and not long ones that do not work on the very next page?

Hello!
I installed an xpath extension for google chrome - but it generates very long and complex XPATHs, which are also not the most convenient.
At the same time, on the Internet, I find xpath options many times shorter - and more convenient.
Why is it so? Is it normal? Or what determines the length and complexity of the xpath?
For example - it is not clear why such a large Xpath is needed (for example, in order to get the data of the "ask a question" button on a toaster - it creates such a complex query

/html[@class='js no-touch svg inlinesvg']/body/div[@class='layout']/div[@id='js-canvas']/div[@class='layout__body']/header[@class='layout__topbar']/div[@class='layout__topbar_suggest']/div[@class='layout__topbar_wrap']/div[@class='layout__topbar_add-question']/a[@class='btn btn_green btn_add-question']

how to simplify it? only manually? Or are there programs or something else for this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan Yakushenko, 2019-09-12
@mmm1919

Hands.
Here is an example for the same button:
You can learn the syntax and see examples here and here .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question