Using Selenium WebDriver to wait for a JavaScript-generated table to be fully loaded and visible

My current challenge involves scraping data from the table of a specific F5 Article (). Sometimes, I am able to successfully extract the tables from the DOM, while other times, the JavaScript-generated tables are not being crawled. Despite my attempts with implicit and explicit waits, I have been unsuccessful in consistently accessing the table data. When using explicit wait, I encounter timeouts and cannot select the table as needed.

Do you have any suggestions on how to reliably retrieve the data within the tables? My current setup includes Java 8, Selenium 3.141.59, and ChromeDriver 85.0.4183.87.

driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
WebDriverWait wait = new WebDriverWait(driver, 15);
WebElement element = wait
    .until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("table")));

Edit: I would prefer to utilize their API for this task, but unfortunately, it is not documented and therefore not an option for me.

Answer №1

How about this code snippet:

List<WebElement> tablesList = driver.findElements(By.tagName("table"));
if (tablesList.size() == 0) {
    try {
        wait.until(ExpectedConditions.presenceOfElementLocated(By.tagName("table")));
        tablesList.addAll(driver.findElements(By.tagName("table")));
    }
    catch (TimeOutException e) {
    };
}

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

Turn off the nicescroll scroll bar that appears as a default feature

Is there a way to disable the nicescroll scroll bar that appears in red by default on my html page? It's causing issues with zooming in and breaking the layout. ...

The most straightforward method to create a unique JPanel background

I'm having an issue with setting the background of my JPanel. I am trying to place my image "aaa.jpg" as the background of panel "p5". Is there a straightforward way to achieve this without creating a new class? How can I set this image as the backgro ...

Selenium: this type of annotation is not suitable for use in this declaration

Is the implementation of the @FindBy annotation incorrect in this scenario? package dur.bounceme.net.SeleniumBase; import java.util.logging.Logger; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.su ...

Having trouble with submitting a form using an external button in React?

class Index extends React.Component { state = {isLoading: false} onSubmit = (event) => { console.log('here we go'); event.preventDefault(); // this.checkEmailExistance(); }; render() { return ( ...

Is there a way to invoke a function from a component that is neither a direct child nor parent component?

Module X let searchQuery = .... retrieveData(searchQuery); Module Y //implementing the use of Module X's parameter ...

What are the steps to conducting a search on mongodb?

My document list is shown below [{"userId": "1", "text": "National security is of utmost importance"}, {"userId": "2", "text": "We must ensure a strong defense while upholding civil ...

What could be causing NVM (for Windows) to malfunction and consistently display error messages every time it is executed?

After attempting to install nvm on my Windows system using https://github.com/coreybutler/nvm-windows, I encountered an error message when running the nvm-setup. Despite reinstalling nvm, resetting the PATH environment variable, and trying to install vers ...

Using Vue.js to invoke an external JavaScript function for search functionality

In my vue.js application, I have a list of users with backend pagination. Now I want to implement a search functionality. I attempted to call the method like this: watch: { search: function() { Crud.methods.getItems(); } }, Howe ...

Getting byte[] type using SoapObjects in an Android project with WCF WebService

In my Android/Java project, I am working with Network threads that are connected to a WCF WebService. The WebService provides a method called GetAddonsTypes which returns long, int, and string items. To handle the response, I have created my own Parser usi ...

Looking to transfer a multimap from Java to JavaScript using JSON

Seeking advice on the most effective way to transfer multimap values from Java to JavaScript in JSON format. In addition to utilizing an object with a key field and an ArrayList, are there alternative methods I could consider for sending multimap values ...

altering the way the array is displayed

Using the GSON library, I am trying to export user inputted arrays to a .json file. How can I write the code in such a way that it exports the information without annotations for easier importing back into the array? Let's take a look at the code and ...

The functionality of iOS 9 is hindering the accessibility of modal mobile links

On my website, I am using modal to display necessary information that requires users to click on buttons such as back and submit. However, the links seem broken even though they are supposed to redirect to another page. Whenever a button is clicked, the pa ...

Error: Element not found - Element cannot be located

Although I am not a programmer, I have an interest in automation and am constantly learning about it. Any advice would be greatly appreciated. Here is the issue I encountered: I attempted to use Python Selenium to log in to the website anywhereconference. ...

Error encountered on Google Chrome due to Firefox web worker functionality being incompatible

Within my web worker, I have a line where I define the onmessage handler as shown below: onmessage = function() {/*...*/} While this code works flawlessly in Firefox, it throws an error in Google Chrome: Uncaught ReferenceError: onmessage is not defined ...

There seems to be an issue with the AJAX REST call failing to transmit data

Whenever I attempt to submit the form, the page refreshes and nothing gets saved in the database. The code in subforum.js $(document).on('click','#submit',function(e) { var user = JSON.parse(sessionStorage.getItem("ulogovan")); consol ...

Generics: implementing interfaces for Enum types

Disclosure: I am not particularly proficient with generics. Suppose there is an Enum structured like this: public enum FirstEnum implements BaseEnum<FirstEnum> { SOMETHING_1(Month.FEBRUARY, MZ_AUGUST, MZ_NOVEMBER), SOMETHING_2(Month.JANUARY, ...

What strategies can I employ to address this historical issue?

Encountered TypeError: (0 , history_history__WEBPACK_IMPORTED_MODULE_6_.default) is not a function This issue arises in my history.js file import { createBrowserHistory } from 'history'; export default createBrowserHistory({ forceRefresh: tr ...

Is it possible to place Angular Material components using code?

Currently, I'm in the process of creating a responsive Angular application. Is there any way to adjust the height and position of the <mat-sidenav-content></mat-sidenav-content> component in Angular Material programmatically without relyi ...

Is there a way to retrieve nested data from a JSON API response?

Trying my hand at creating a basic CLI cryptocurrency tracker app. The app runs a successful API call and provides the following output: [ { exchange: 'binance', base: 'ADA', quote: 'BTC', price_quote: '0.000 ...

Viewing a Google Charts graph upon the loading of a web page

Utilizing the Google Charts library, I have incorporated a graphic on my web page that is dynamically added using AJAX into a <div> element. To display the graph when the page loads, I have written the following code: <script type="text/ ...