N
N
niokledeon2020-08-15 09:17:11
Python
niokledeon, 2020-08-15 09:17:11

How to find element in last selenium class?

Hello, I ran into this problem... There are many identical classes ("display-container") on the page. I need to find only the last of these classes, and they already have a similar situation, I need to find ("link-container"), where there will be another class ("t-actions"), where finally there will be 3 buttons. You need to find the second button, (I marked the name of the button in the code). I would be grateful for any help!

<main class="main">
  <div class="wrapper">
    <div class="grid">
      <div class="row">
        <div class="col-1">...</div>
        <div class="col-2">...</div>
        <div class="col-3">
          <div class="display-container">...</div>
          <div class="display-container">...</div>
          <div class="display-container">...</div>
          <div class="display-container">...</div>
          <div class="display-container">
            <div class="display-header">...</div>
            <div class="display-wh">...</div>
            <div class="display-items">...</div>
            <div class="note-container">...</div>
            <div class="link-container">
              <div class="t-actions">
                <p>
                  <a href="/button1" class="btn-secondary">Button1</a>
                  <a href="/button2" class="btn-secondary">Button2 (та кнопка которая нужна)</a>
                  <a href="/button3" class="btn-primary">Button3</a>
                </p>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</main>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Daria Motorina, 2020-08-15
@niokledeon

There are examples in the "order selectors" section ( xpath cheatsheet ) It is
possible to construct an xpath selector with the Nth element and the last element. To debug such an expression, you can put an extension for xpath in the browser, it will be faster than running the code

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question