0

Unable to click on Radio Buttons, once the popup has loaded

*Please note i have raised a question in the past but i want to avoid using Thread.sleep
Link:

Scenario (Successful)
1. If i access any hut directly via the following URL:
2. Iam successfully able to click on the link which is selecting the radio button 'Order for later'


Scenario (Not Successful)
1. If i access the Pizza Hut URL:
2. Click Pizza Button
3. Click any 'Pizza Type' Start your Order button
4. When the localisation page appears > type postcode 'AL1 2PS' > click find a hut
5. My Script is unable to click on the 'Order for Later' radio button
6. But in the Successful scenario iam able to click on the link?
7. I have tried many waits and custom waits, js waits but the only time Iam successfully able to click on the link is using Thread.sleep()

Please could anybody advice on a solution to the problem?

Many thanks for you help

Community
  • 1
  • 1
Gbru
  • 1,065
  • 3
  • 24
  • 56

1 Answers1

1

You didn't post any code so I'm not sure what all you have tried. I wrote the code below and it works.

String pizzaType = "Hawaiian"; // the pizza type from the Pizza menu
String postcode = "AL1 2PS";
String url = "https://www.pizzahut.co.uk/";
driver.get(url);
driver.findElement(By.linkText("Pizza")).click(); // click Pizza menu
driver.findElement(By.xpath("//h3[text()='" + pizzaType + "']/../../../..//button")).click(); // click a pizza type specified by pizzaType
driver.findElement(By.id("ajax-postcode-txt")).sendKeys(postcode); // enter a postcode
driver.findElement(By.id("get-store-btn")).click(); // click "Find a Hut"
driver.findElement(By.cssSelector("input[data-value='later']")).click(); // click "Order for later"
JeffC
  • 22,180
  • 5
  • 32
  • 55
  • 1
    If this answered your question, please mark it as accepted and if you found it useful (or any answer for that matter) please upvote it. – JeffC Oct 03 '16 at 14:08