WebDriver: Patiently awaiting the 'JS Popup Screen' to load without relying on Thread.sleep()

Having trouble clicking on Radio Buttons after the popup loads

*Note: I have brought up this issue previously, but I am looking for an alternative to using Thread.sleep
Link:

Successful Scenario:
1. When directly accessing a hut using this URL, I can click on the 'Order for later' radio button successfully.

Unsuccessful Scenario:
1. Navigating to the Pizza Hut URL:
2. Clicking Pizza Button
3. Choosing any 'Pizza Type' and clicking 'Start your Order' button
4. On the localisation page, entering postcode 'AL1 2PS' and clicking find a hut
5. My script fails to click on the 'Order for Later' radio button
6. Despite trying various types of waits such as custom and JavaScript waits, I am only successful with Thread.sleep() which I want to avoid.

If anyone has advice or a solution to offer, it would be greatly appreciated.

Thank you for your assistance.

Answer №1

No code was provided, so it's unclear what attempts have been made. Here is a snippet of code that I've written and successfully tested:

String pizzaType = "Pepperoni"; // the type of pizza selected from the menu
String postcode = "SW1A 1AA"; 
String url = "https://www.dominos.co.uk/";
driver.get(url);
driver.findElement(By.linkText("Menu")).click(); 
driver.findElement(By.xpath("//h3[text()='" + pizzaType + "']/../../../..//button")).click(); 
driver.findElement(By.id("postcode-input")).sendKeys(postcode); 
driver.findElement(By.id("find-store-btn")).click();
driver.findElement(By.cssSelector("input[data-value='collection']")).click(); 

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

Executing the JavaScript function only a single time is what you're looking

I'm having trouble getting this script to work correctly on my website. It is supposed to trigger an alert when the specified id is in the viewport, but the issue I am encountering is that the alert keeps popping up repeatedly while the id is still vi ...

Selenium Grid: Unable to locate the DevToolsActivePort file (error: Chrome did not launch successfully and exited abnormally)

Recently, I decided to use Selenium Grid to automate some tests. To make the process more efficient, I set up VMs running on a LINUX Platform (one acting as a Selenium hub and others as Selenium nodes). The standalone server started without any issues in b ...

The function angular.isDefined(obj) will fail to work when the variable "obj" is not defined

Typically, I find myself using the slightly cluttered typeof obj !== "undefined" expression. But recently, I came across the angular.isDefined(obj) function. According to the documentation, it should return false if the object is not defined. However, in ...

Error: The term "Particles" has not been defined

I'm attempting to integrate code from a website into my project, but encountered an error when the particles failed to run after adding it. I downloaded and installed particle.js from "https://github.com/marcbruederlin/particles.js/issues" for this pu ...

Is there a way to prevent Angular component lifecycle hooks like ngOnInit/ngOnDestroy from being triggered when nested within one another?

I am currently developing an application with a page structure that resembles the following: Displaying Objects retrieved from Firestore (similar to Instagram posts) Loading Comments (using the object's id to display comments sub-collection) Load ...

Having trouble accessing env variables from React Component in Next.js?

I recently set up a Next.js project and included an .env file to store environment variables used in my server.js file. However, I am facing an issue when trying to access these variables from a component. Can anyone provide guidance on how to resolve this ...

Is it possible to serialize java.util.Set to a JSON array in ascending sorted order using Jackson ObjectMapper?

I have a collection of comparable objects in a Java Set that I want to serialize to a JSON array in ascending order. Is there a way to achieve this with Jackson's ObjectMapper? If not, I am considering creating a custom serializer for the Set. Any be ...

Messages are not being received despite no errors occurring in the PHP form

I am facing a challenge with a PHP script that is supposed to send a form, but it keeps saying the email has been sent while nothing actually shows up. Do you have any insights on what might be causing this issue? Also, there's nothing in the spam fol ...

AngularJS Currency Converter - Converting Currencies with Ease

I have a question regarding the most efficient way to handle currency conversion on a webpage. Currently, I have multiple input fields displaying different currencies. When a user clicks on the currency conversion button, a modal popup appears. After the ...

The JSX in React won't display the modified state on the user interface

In my diary object, I have records of 2 meals function Magicdiary() { const [diary, setDiary] = React.useState<MagicDiaryDay[]>([ { mealName: "Breakfast", ingredient: null }, { mealName: "Lunch", ingredient: null }, ]) ...

Establish a MongoDB river in Elasticsearch using the Java API

Currently, I am attempting to utilize the Java API to establish a new connection between MongoDB and ElasticSearch. The process is straightforward when using the REST API by sending a PUT request with the specified JSON code below: { "type": "mongodb", ...

The JavaScript function is not executing the Node.js code as expected

Currently, I am utilizing Twilio to send a sample message when running the provided code in the terminal: var accountSid = '...'; var authToken = '...'; var twilio = require('twilio'); var client = new twilio(acco ...

A step-by-step guide to displaying a label component upon clicking an AjaxLink

How can I display data from a JSON file when an AjaxLink is clicked? The code I have implemented is not working, so I would appreciate any corrections or suggestions. Additionally, I am wondering if it's possible to add a label inside AjaxLink. Thank ...

Enhance your coding experience with Firebase Autocomplete on VScode

Recently, I installed VScode along with the necessary packages for JavaScript development. As I started writing code involving Firebase, I noticed that the autocomplete feature, which worked perfectly fine in Xcode, was not functioning in VScode. How can I ...

Save a SQL query as a text file using Node.js

I'm having an issue with my code. I am trying to save the results of a SQL query into a text file, but instead of getting the actual results, all I see in the file is the word "object." const fs = require('fs'); const sql = require('mss ...

Perform the MongoTemplate.aggregate operation without retrieving rows

I'm currently utilizing the Spring Mongo driver to execute a substantial mongo aggregation operation that will have a lengthy run time. The final stage of this aggregation entails writing the results into a fresh collection, without any need to retrie ...

Investigating the variety of HTTP 206 responses pertaining to video content

Currently, I am utilizing Amazon CloudFront to serve HTML5 videos. These videos are being requested through HTTP range requests and the expected responses are often in the form of HTTP 206 Partial Content. I have a requirement where I want to log the requ ...

Which function is most suitable for verifying if the values from req.param are NaN and assigning a new value if they are found to be NaN?

Regarding the about page: I'm currently working on a react app that sends URL parameters to the backend server. The frontend URL looks something like this: maxprice=100000&minsqm=50&maxsqm=100&page=1, which are the user's filters for ...

Tips for automatically closing all other divs when one is opened

I have multiple divs structured like this: <div id="income"> <h5 onclick="toggle_visibility('incometoggle');">INCOME</h5> <div id="incometoggle"> <h6>Income Total</h6> </div> </div> <d ...

Utilize the Mongo Java Driver to retrieve information from a MongoDB database

Currently, I am embarking on a Java program creation journey that involves connecting to a MongoDB database. I have all the essential details, including the server, port, database name, userDB, and username/password for the MongoDB database that I intend t ...