Search code examples
c#seleniumselenium-webdriverselenium-chromedrivergoogle-forms

Use selenium click check box google form


I want to use selenium chrome click check box in google form demo in this link

Google form demo

This is my code:

var ElementMulti = driver.FindElements(By.ClassName("quantumWizTogglePaperradioOffRadio"));

foreach (IWebElement element in ElementMulti)
{
    element.Click();
}

The code does not work. How can I fix it?


Solution

  • System.setProperty("webdriver.chrome.driver", "chromedriver");              
    driver = new ChromeDriver();
    
    driver.get("https://docs.google.com/forms/d/e/1FAIpQLSee-3p39HAeLYchK1UMin_KPDB_E40GNkbYFS5u-sz0Pza_Rg/viewform");
    Thread.sleep(2);
    
    // Radio 1 select
    driver.findElement(By.xpath(".//*[@id='mG61Hd']/div/div[2]/div[2]/div/div[2]/div/content/div/label[1]/div/div[1]/div[3]/div")).click();
    Thread.sleep(2);
    
    // Radio 5 select
    driver.findElement(By.xpath(".//*[@id='mG61Hd']/div/div[2]/div[2]/div/div[2]/div/content/div/label[5]/div/div[1]/div[3]/div")).click();
    Thread.sleep(2);
    
    // Submit button clicked.
    driver.findElement(By.xpath("html/body/div[1]/div[2]/form/div/div[2]/div[3]/div[1]/div/div/content/span")).click();
    Thread.sleep(2);
    
    driver.close(); 
    

    This is selenium java code. And it's working fine.

    It opened the given link and then click on the first radio button the last radio button and then clicked on the submit button.