Looking to verify the display property of a div element in Selenium WebDriver (WDS) with J

Greetings StackOverflow Community,

I am new to Jmeter and all related aspects.
I find myself in need of assistance. While I am searching for something, there is a div that appears during the waiting period which prevents me from clicking on other elements.

<div id="wait" width="100%" height="100%" class="wait" style="position: absolute; top: 0px; left:0px; height: 617px; width: 355px; display: block; cursor: default;"></div>

Once the search is complete, it transforms into

<div id="wait" width="100%" height="100%" class="wait" style="position: absolute; top: 0px; left:0px; height: 617px; width: 355px; display: none; cursor: default;"></div>
essentially changing its display from 'block' to 'none'

According to the requirements of my application, I need to wait until the 'wait' div's display status changes to none before interacting with other elements.

How can I check this using WDS JavaScript?
I have attempted:
wait.until(conditions.presenceOfElementLocated(pkg.By.xpath(".//*[@id='wait'and not(@style.display)]")));

However, it does not seem to be working as expected.

Any help in this regard would be greatly appreciated. Thank you.

Answer №1

One option is to pause until the element becomes visible.

wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//."));

Answer №2

Instead of waiting for the visibility of an element and using a potentially unreliable XPath selector, I highly recommend waiting for the element to become invisible:

wait.until(conditions.invisibilityOfElementLocated(pkg.By.id("wait")));

Furthermore:

  1. Whenever possible, target elements by their IDs since it is the fastest and most reliable method
  2. If you choose to use XPath, avoid using wildcard queries like .//*[; instead, try limiting your search to specific elements like //div.
  3. If you encounter any unexpected behavior, refer to the jmeter.log file - it will likely provide insights into script failures
  4. For more tips and tricks on WebDriver Sampler, take a look at the article titled The WebDriver Sampler: Your Top 10 Questions Answered

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

Conceal & reveal divs when browsing from a mobile device

I am currently working on a project where I have a div called #bob_show that is visible, and another one called #slider_mobile that is hidden when the website is viewed on a desktop browser. However, I need these statements to be reversed when the website ...

What is the process for changing the background color when a button or div is pressed, and reverting the color back when another button or div is

Looking to customize a list of buttons or divs in your project? Check out this sample layout: <button type="button" class="btn" id="btn1">Details1</button> <button type="button" class="btn" id="btn2">Details2</button> <button ty ...

How to show multiline error messages in Materials-UI TextField

Currently, I am attempting to insert an error message into a textfield (utilizing materials UI) and I would like the error text to appear on multiple lines. Within my render method, I have the following: <TextField floatingLabelText={'Input Fi ...

jQuery code isn't functioning properly when I include the script using the complete URL

When I include the local jQuery like this, everything works fine: <script type="text/javascript" src="jquery-1.11.2.min.js"></script> However, when I try to link it from my server, things don't work as expected. I double-checked by openi ...

Select the Initial Airport Code from the Pre-filled Dropdown List using Selenium WebDriver in Java

Looking to automate the Flight page for the URL provided below: URL: In the 'Flying From' Textbox, input LAS and observe the auto-populated list of airports. The task is to select the first airport code that matches from the list. I aim to aut ...

Using Vue: How to utilize v-slot variables in JavaScript

Can the values of the v-slot of a component be accessed in the script? For instance, consider the following template: <cron-core v-model="value" :periods="periods" :format="format" v-slot="{fields, period, error}"> {{period}} <div v-for="fiel ...

Retrieving the value of a JavaScript variable from an HTML document using Python

I am looking to extract the value of myJSONObject from an HTML document that includes javascript code with a JSON object. Here is an example snippet: <html> <head> </head> <body> <script type="text/javascript"> ...

Express JS sub child routes are experiencing issues with static files not functioning properly

I used express-generator to create my project structure. In app.js, the code is as follows: var createError = require('http-errors'); var express = require('express'); var path = require('path'); var cookieParser = require(&a ...

Having trouble retrieving information from an external local json file

I'm attempting to display an 'alert' box containing text retrieved from a JSON file. However, I'm facing issues in fetching data from the JSON file and the alert box is not being displayed. var thebook = JSON.parse(book); function s ...

Enhance text by hovering over it

I am currently working on implementing a unique feature using jQuery and CSS. Rather than just inheriting the width, I want to create a magic line that extends to the next index item. Scenario: 1: Hover over Element one ELEMENT ONE ELEMENT TWO ELEM ...

calling object functions using additional parentheses

After reviewing the passport.js documentation, I came across this piece of code: app.get('/login', function(req, res, next) { passport.authenticate('local', function(err, user, info) { if (err) { return next(err); } if (!u ...

Search for a DIV element within iMacro on a consistent basis

I recently started using iMacro and encountered an issue while recording a script that involved clicking on a pop-up when it appeared on the screen. The problem arose because the pop-up only appears when a new event is posted. Therefore, when I initially c ...

Axios and fetch returned distinct status codes when querying the same external endpoint

I am attempting to make a request to the following endpoint: https://9gag.com/v1/group-posts/group/default/type/trending in order to retrieve 9gag posts data. Everything works smoothly when I use postman and chrome, however, when I attempted to make the r ...

Can arrays be passed as function parameters in CrossRider without the need to convert them into objects first?

Our team is currently utilizing CrossRider to develop an extension specifically for Internet Explorer. We have a crucial object that is downloaded from , but we are facing an issue where arrays within this object are getting converted into objects with int ...

Tips for utilizing v-for in Vue.js to iterate through a JSON object and distribute the resulting elements into two separate div containers

One of my challenges involves using an Axios callback to receive a JSON array with 170 key:value pairs. I then utilize v-for to display each pair within its own div container nested in another div wrapper, resulting in a column layout. I aim to generate t ...

issue with webdriver manager when operating through a proxy server

When trying to use webdriver-manager for execution, I encountered the following issue: webdriver-manager update --proxy=https://proxy.company.com:8080 Upon running the command above, I got the following error message: webdriver-manager: using local ins ...

The Slack Bot is having trouble downloading files from direct messages, but it is successfully downloading them when uploaded to a channel

I have developed a program to retrieve files using a code snippet provided by a Slack bot. Below is the code: var https = require('https'); var fs = require('fs'); var downloadFile = function (url, dest){ var slug = url.split(&apos ...

What is the best way to dynamically update or display unique CSS styles when a service is invoked or provides a response in AngularJS using JavaScript

Seeking to display a unique CSS style on my HTML FORM prior to invoking a service in my code and then reverting back after receiving the response. I have implemented the use of ng-class to dynamically add the class when the boolean activeload1 is set to tr ...

The functionality of Angular's ng-change or ng-click for select elements is not functioning properly

Exploring the concept of ng-change with checkboxes in this example. Check out the live example here Attempting to convert checkboxes into a selection but encountering some challenges. Here is the code snippet: <select> <option ng-model="confi ...

Is the Angular $watch function able to track changes on an object's prototype members as well?

I have encountered a challenge with a tree structure implemented in Javascript which has circular references. The objects in the structure contain an array of children, but these children also need to reference their parent for deletion purposes. To monit ...