Unable to click on a radio button in Selenium Webdriver

后端 未结 8 413
遥遥无期
遥遥无期 2021-01-23 21:11

I am learning Selenium Webdriver using Java. As a learning example, I tried to open MakeMyTrip, access International Flights page and click on One Way radio but

相关标签:
8条回答
  • 2021-01-23 22:02

    Try below xpath.

    //*[@id="one_way_button1"]/span/input
    

    It should work.

    driver.findElement(By.xpath(//*[@id=\"one_way_button1\"]/span/input)).click();
    
    0 讨论(0)
  • 2021-01-23 22:05

    Use below code :-

        if(displayFlag==true && enableFlag==true)
        {
            try{
            Thread.sleep(5000);
            }
            catch(Exception ex)
            {
                System.out.println(ex.getMessage());
            }
            WebElement element=driver.findElement(By.xpath("//span[@class='radio_state']"));
            JavascriptExecutor executor = (JavascriptExecutor) driver;
            executor.executeScript("arguments[0].click();", element);
            System.out.println("Tried to click One Way");
        }
    

    enjoy .. get back to me if still getting any issue :)

    0 讨论(0)
提交回复
热议问题