A
A
artbotva2020-01-12 13:07:52
C++ / C#
artbotva, 2020-01-12 13:07:52

How to get last div element in c#?

In general, there is such a piece of html.
5e1aef3f941b5763831945.png
I need to get the text from the last div element. For example, at the moment I get the ninth element like this:

var textmsg = webDriver.FindElement(By.XPath("//*[@id='main']/div[3]/div/div/div[2]/div[9]/div/div/div/div[1]/div/span[1]/span")).Text;
                string textmsgS = Convert.ToString(textmsg);
                Console.WriteLine(textmsgS);

But as I said, I need to get exactly the last element. Thanks in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Korotenko, 2020-01-12
@firedragon

It is logical to call the last function
https://xsltdev.ru/xpath/last/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question