Utilize Selenium's explicit wait feature to wait until a group of buttons on a web page become clickable

On a webpage, there is a collection of buttons. Each button has the same source code except for the link text.

I am looking to verify that all the buttons on the page are clickable using WebDriverWait.until. Currently, I can confirm the clickability of the first button with

WebDriverWait(driver,10).until(ec.element_to_be_clickable(By.XPATH,'//a[@class="ng-scope"]'))
But how do I ensure the second button is clickable without relying on its specific text (abc|efg)?

Does anyone have suggestions on how to extract the index within the xpath? Thank you.

<li class="ng-scope" ng-report="one in typelist">
    <a class = "btn ng-binding" ng-class="{aabbcc}"> abc</a>
</li>
<li class="ng-scope" ng-report="one in typelist">
    <a class = "btn ng-binding" ng-class="{aabbcc}"> efg</a>
</li>

Answer №1

To ensure maximum efficiency, compile all elements into a list and then systematically assess each for clickability.

Answer №2

If you want to locate elements using xpath, you can specify the index.

WebDriverWait(driver, 10).until(ec.element_to_be_clickable(By.XPATH, "//a[@class='ng-scope'][2]"))

With this code snippet, you'll be able to target the second button on the webpage.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

A helpful tip for determining the size of a table: exclude the first and last rows to get an accurate

I'm encountering an issue with a table that has a header (1 row) and footer (1 row). When I try to get the table size, I expect the value to be 50 but it actually returns 52 because it's counting both the header and footer rows. Is there a way to ...

jQuery form validation with delay in error prompts

I am experiencing a strange issue with my HTML form validation function. It seems to be showing the alert div twice, and I can't figure out why this is happening. Adjusting the delay time seems to affect which field triggers the problem. Can anyone sp ...

"Learn the techniques for toggling the visibility of a separate iframe through a hyperlink

<div class="category-tab" id="navg"><!--category-tab--> <div class="col-sm-15"> <ul class="nav nav-tabs"> <li class="active" ><a href="link" data-toggle="tab">name</a></li> <li ><a href="#link" dat ...

What is the mechanism behind the setTimeout function as an asynchronous timer when we specify a specific duration?

Can you identify the coding instructor, possibly Net Ninja or Fireship, who explained that in asynchronous setTimeout, it promises to run after a minimum time of 1 second but may actually take longer (e.g. 1015 milliseconds or 1200 milliseconds)? What ha ...

Properly saving intricate form information in a React application

In my React project, I have a complex form consisting of multiple sub-components. Some parts of the form use nested objects as data, making it a bit challenging to manage. The main component, referred to as EditForm, holds the entire object tree of data. ...

Exploring the functionality of iterating through a JSON array of objects with a foreach loop in both JavaScript and Jade

I have a json array that I am trying to display using foreach loop. However, it takes five iterations to show all the data when I would like it to be displayed in a single iteration. How can I achieve this? Below is the jade file code snippet: each item i ...

Why won't hover over function properly in separate divs for two items?

My goal is to show text when hovering over a logo, but the text and logo are in different divs. Despite trying various solutions like using display: none and display: block, I still can't get it to work. import styles from '../styles/Float.module ...

Simple code styling tool

Seeking guidance to create a basic syntax highlighter using JavaScript or ClojureScript. While aware of existing projects like Codemirror and rainbow.js, I'm interested in understanding how they are constructed and looking for a simple example. Do th ...

Troubleshooting issue with Bootstrap's responsive scrollspy functionality

I am experiencing an issue with the responsiveness of my page. When I reduce the width of the page to half, the scrollspy disappears unexpectedly. I am unsure about the root cause of this problem. If you run the code I have shared here, you can observe th ...

The process of retrieving an item from an HTML node using Vue.js

My scenario involves a Vue app with the following data: data: function() { return { items: [ {id: 1, text: 'one', other_data: {}}, {id: 2, text: 'two', other_data: {}}, {id: 3, text: &apo ...

Fixing SSL errors in Selenium with Chrome: An in-depth guide

Can anyone explain to me why every site I try to open with Selenium WebDriver is showing an SSL certificate error? It's important for me to maintain a secure connection. I am aware that this issue can be "solved" by adding options.add_argument(' ...

Is it possible to trigger a directive using a function and then access the generated style?

My directive is designed to randomly select a color and assign it to a new user as an avatar. The random color generation and directive functionality are working as expected, but I'm looking to expand the functionality further and need some assistance ...

Using a relative path in Ajax is ineffective

I am facing an unusual issue with AJAX. The HTML page I am working on is calling an AJAX function from this location: public_html/test/books.html The AJAX file that needs to be called is located here: public_html/lists/include/vote_up.php I have tried ...

Facing issues with C# Selenium where the Click, Clear, and SendKeys functions are not working correctly except when in Debug mode

Struggling with a problem where commands to change date fields only work intermittently, and the root cause is unclear. However, when running them in Debug mode with step-by-step execution, everything functions as expected. Here's a snippet of code fr ...

Refresh a table using jQuery Mobile, PHP, and AJAX without having to reload the entire page by clicking a

Currently, I am working on a web app that includes a pop-up feature. When the user clicks on the pop-up to close it, I want the table data to refresh without having to reload the entire page. This pop-up allows users to modify existing data in the table. A ...

ReactJS is giving me an error message: "Uncaught TypeError: Unable to access property 'ownerDocument' since it is null."

Trying to create a bar chart using D3 and render it with React's render method. Below is my index.js file: import React from 'react'; import ReactDOM from 'react-dom'; import './Styles/index.css'; import BarChart from &a ...

Using Python and Selenium to retrieve information from the attribute 'data-label'

https://i.stack.imgur.com/zb7f5.jpg try: details = WebDriverWait(driver, 10).until( EC.presence_of_element_located((By.ID, "DataTables_Table_5")) ) scores_list = details.find_elements_by_tag_name('tbody') for sco ...

Exploring the application of conditional logic within HTML coding

I am working on ensuring that Part II of the HTML page only runs once all required information has been successfully submitted through the form. This particular issue is within a Flask application. I need to run Part II after Part I in order to prevent an ...

Tips for applying a class to an element depending on data stored in Local Storage using JQuery

I am currently working on a TODO list project with functions to save and delete records already in place. However, I am facing challenges with the functions for marking items as important and done. One method I use is to retrieve saved items from Local St ...

What is the best way to access the "parent name" and extract information from the object within an ng-repeat loop in AngularJS?

Assuming I have a response object structured like this: Object Json format in my JavaScript file. I want to utilize ng-repeat for this element but also retrieve the name "street 1". How can I use ng-repeat to access all values under the parent name along ...