The button appeared to be clicked, yet the element.click() function was executed in the Selenium script

I am currently working on automating a Pega Web application using a script. I have implemented button click functionality, but for some reason, the button is not being clicked when I run the script. The logs indicate that the action was performed, but the button remains unclicked.

I have attempted various solutions without success, such as:

WebDriverWait wait = new WebDriverWait(driver, 80);
            wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//button[contains(text(),'Submit')]")));

driver.findElement(By.xpath("//button[contains(text(),'Submit')]")).click();

Afterwards, I tried another approach:

WebDriverWait wait = new WebDriverWait(driver, 80);
            wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//button[contains(text(),'Submit')]")));

WebElement button=driver.findElement(By.xpath("//button[contains(text(),'Submit')]"));

button.sendKeys(Keys.RETURN);

I also experimented with JavaScript:

JavascriptExecutor jse = (JavascriptExecutor) driver;
    jse.executeScript("arguments[0].click();", button);

Answer №1

I've encountered a similar issue on numerous occasions, and I managed to resolve it with the following workaround:

while(driver.findElements(By.xpath("//button[contains(text(),'Submit')]")).size()!=0)
{
    driver.findElement(By.xpath("//button[contains(text(),'Submit')]")).click();
}

This solution is just temporary, as I discovered it online. It seems to be an issue with the driver itself.

---- Update ----

Prior to clicking the button, ensure that the page has fully loaded (including Ajax) using the JavaScript commands below:

jQuery.active == 0 && document.readyState == "complete"

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

Tap twice on Kendo Grid rows in the React Component

I am currently utilizing the React Grid component and I am in search of a solution to trigger a function when a row is double-clicked. While I have found a rowClick function that allows me to select a row or handle an onClick event: <Grid rowClick={e = ...

`Cannot Get jQuery ScrollTop Function to Work for 2nd Element`

Having trouble with an issue. Let me explain. I implemented a scrollTop Jquery on page load that scrolls down after a delay to prompt user action. However, I'm facing a problem where another scrollTop doesn't work after clicking buttons "#b3,#b3 ...

Endless Cycle of Facebook Login

I'm encountering an issue with the Facebook Login feature on my website. At first, I tried using only FB.Login but received the message: "FB.login() called when user is already connected." So, I added FB.getLoginStatus to address this problem. Howeve ...

What causes delayed state updates in React/NextJS until another state is updated or a fast refresh occurs?

UPDATE: Version 13.3.0 is coming soon! In my code, I have a state variable named localArray that I need to update at a specific index. To achieve this, I decided to create a temporary array to make modifications and then set the state with the updated val ...

Measuring vocabulary through synchronized Java arrays

Struggling with creating a code to calculate the frequency of words in an array. Is it necessary to use nested loops to keep track of both the word array and integer array? Despite spending hours on this, I haven't been able to make any progress. Any ...

An easy way to place text along the border of an input field in a React JS application using CSS

I am struggling to figure out how to create an input box with text on the border like the one shown in the image below using CSS. I have searched extensively but have not been able to find any solutions to achieve this effect. I attempted using <input&g ...

Resetting clears the date default value

When the page is loaded, the date input field is automatically set to the current date. However, if the form is reset, instead of restoring the default date, the date field is cleared, as shown in the images below: Page load Form reset // app.component. ...

Showcasing the time variance using javascript/jquery

I am currently using a datepicker to select dates, with the intention of calculating the difference between the chosen dates and then displaying an alert with the calculated difference. Unfortunately, I am encountering issues with getting the code to work ...

Undo changes in Sequelize transaction using a specific rollback target

In my current project, I am utilizing managed transactions. There is a specific scenario where I need to implement a single transaction and revert to a certain savepoint if it encounters an error, but still ensure that the changes are committed in the end. ...

The app.html for the skygear/react-chat-demo is malfunctioning

I followed the instructions provided in the Skygear manual at https://docs.skygear.io/guides/advanced/server/ The skygear-server-darwin-amd64 started successfully. Then, I attempted to run the react-chat-demo project from https://github.com/skygear-de ...

Scrolling down a jQuery div after each new item is added.OR

I have a div acting as a chat feature, where messages are appended based on user actions. I am trying to make it so that the div automatically scrolls down after each message is added, but I'm encountering some issues with this functionality. You can ...

Utilizing Angular2 Guard to Ensure False IdentityServer4 OIDC Security

After successfully authenticating a user and redirecting them back to the main site, the following code runs: <script src="https://cdnjs.cloudflare.com/ajax/libs/oidc-client/1.2.2/oidc-client.min.js"></script> <h1 id="waiting">Waiting... ...

Challenges faced with Vuetify's vertical and non-linear stepper components

I've been struggling to grasp the concept of Vuetify's stepper feature. Despite my efforts, I haven't been successful in combining different steppers from their page that each have elements I need but lack others. One example is this one on ...

Is it possible to contrast a specific character with an array of characters?

package loopPractice; import java.util.Scanner; public class ReplaceVowels { static Scanner scanner = new Scanner(System.in); public static void main(String[] arguments) { System.out.print("Enter a word: "); String input = scanner.nextLine(); ...

Changing MongoCollection<Document> to DBCollection in SpringBoot from version 1.5.4 to 2.1.0.RELEASE

Recently, I made an upgrade to my SpringBoot version from 1.5.4 to 2.1.0.RELEASE. However, after the upgrade, a specific piece of code is causing issues. MongoCollection<Document> collection1 = mongoTemplate.getCollection(collection); MapReduce ...

Verify whether a specific value is present within a nested array in MongoDB

Looking to verify whether a value sent in a request already exists within an array associated with a particular User. The data structure is as follows: { "_id": "63233972df0f14076e027106", "firstName": "mako" ...

How is the server architecture typically designed in a node.js application?

Currently, I am developing a node.js application using socket.io and I'm seeking advice on how to structure the folders properly. The files that I have in my project include: Server.js package.json Additionally, I have: Client.js Index.html Incl ...

Querying MongoDB using aggregation to find documents with a specific date range difference

I have been working on setting up a cron job to synchronize my documents. The goal is for the job to attempt syncing a specified number of times, but only after waiting at least 2 hours since the last attempt. Each document has a "lastSyncAt" field that I ...

Combining Angular JS 1 and Laravel 5.2 for seamless integration

Currently, I am in the process of setting up Angular JS 1 with Laravel 5.2 by installing the necessary dependencies using npm. After installation, a node_modules folder was created alongside the app directory. My primary concern is whether it is recommend ...

Managing "unprocessed information" in a Node.js environment and transferring the information through a Node Express endpoint

Currently, I am in the process of making an API call to retrieve a file using axios: async function fetchData() { const configuration = {}; // { responseType: 'stream'}; const { response } = await axios.get(URL, configuration); c ...