Click on a generic element from a generic list

Hello,

Need a help with some ideas how to click on a generic element from a generic list in Robot Framework using Python.

For example, I need to select last list element, that is <div class="venue-item">, from the following list: <div id="list">. And click on the following tag <a href="#" class="venue-actions dropdown-toggle" data-toggle="dropdown"></a>

May be to create a Python library?

I updated the code to be more clearly, that wanted tag to click is repeating in all generics parent DIV tags

<div id="list" class="row" style="opacity: 1;">
  <div class="venue-item">
      <a class="venue-actions dropdown-toggle" data toggle="dropdown" href="#"></a>
      <ul class="dropdown-menu">
      <h3>test_by_alex_lggge</h3>
      <a class="show-details-btn" href="#">
  <div class="venue-item">
      <a class="venue-actions dropdown-toggle" data toggle="dropdown" href="#"></a>
      <ul class="dropdown-menu">
      <h3>test_by_alex_lggge</h3>
      <a class="show-details-btn" href="#">
  <div class="venue-item">
      <a class="venue-actions dropdown-toggle" data toggle="dropdown" href="#"></a>
      <ul class="dropdown-menu">
      <h3>test_by_alex_lggge</h3>
      <a class="show-details-btn" href="#">
  <div class="venue-item">
      <a class="venue-actions dropdown-toggle" data toggle="dropdown" href="#"></a>
      <ul class="dropdown-menu">
      <h3>test_by_alex_lggge</h3>
      <a class="show-details-btn" href="#">
  <div class="venue-item">
      <a class="venue-actions dropdown-toggle" data toggle="dropdown" href="#"></a>
      <ul class="dropdown-menu">
      <h3>test_by_alex_lggge</h3>
      <a class="show-details-btn" href="#">
  <div class="venue-item">
      <a class="venue-actions dropdown-toggle" data toggle="dropdown" href="#"></a>
      <ul class="dropdown-menu">
      <h3>test_by_alex_lggge</h3>
      <a class="show-details-btn" href="#">
  <div class="venue-item">
      <a class="venue-actions dropdown-toggle" data toggle="dropdown" href="#"></a>
      <ul class="dropdown-menu">
      <h3>test_by_alex_lggge</h3>
      <a class="show-details-btn" href="#">
  <div class="item-detail">
      <a class="venue-actions dropdown-toggle" data toggle="dropdown" href="#"></a>
      <ul class="dropdown-menu">
      <h3>test_by_alex_lggge</h3>
      <a class="show-details-btn" href="#">
 </div>
 <div class="organisation-details">
 <div id="delete-schedule-26681" class="modal fade" role="dialog">
 </div>
</div>

try next xpath:
1.

"//div[@id='list']/div[@class='item-detail']/a[@class='venue-actions dropdown-toggle']"

OR
2.

"//a[@class='venue-actions dropdown-toggle']"

OR
3.

"//div[@id='list']"       click
wait to be visible   "//div[@class='item-detail']"
"//div[@class='item-detail']"     click
wait to be visible   "//a[@class='venue-actions dropdown-toggle']"
"//a[@class='venue-actions dropdown-toggle']"     click
1 лайк

Thanks, looks good.
But I did a mistake and didn’t mention that wanted tag is repeating in all parent div tags.
I updated description.

try next xpath:
1.

"//div[@id='list']"       click
wait to be visible   "//div[@class='item-detail']"
"//div[@class='item-detail']"     click
wait to be visible   "(//a[@class='venue-actions dropdown-toggle'])[last()]"
"(//a[@class='venue-actions dropdown-toggle'])[last()]"     click

OR
2.

"//div[@id='list']"       click
wait to be visible   "//div[@class='item-detail']"
"//div[@class='item-detail']"     click
wait to be visible   "(//a[@class='venue-actions dropdown-toggle'])[8]"
"(//a[@class='venue-actions dropdown-toggle'])[8]"     click

OK, thanks a lot, Yaroslav.
I will be back ASAP with a response in case I succeeded.

better to use contains while searching elements with split classes,[contains(@class,‘venue-actions’) and contains(@class,‘dropdown-toggle’)] instead of @class=‘venue-actions dropdown-toggle’

1 лайк

Hi Yaroslav,

Checked finally.
I used your idea with “[last()]” and it works.

My xpath looks following: //div[@id="list"]/div[@class="venue-item"][last()]/a[@data-toggle="dropdown"]