简体   繁体   中英

I cannot access radio button with selenium webdriver in c#

I cannot access the radio button with chrom websriver in selnium. I am writing my code in c# here is the code I am using

driver.FindElement(By.CssSelector("input[name=eventCategoryID]")).Click();
driver.FindElement(By.CssSelector("input[value=11]")).Click();

for this radio button

You are missing some quotation marks. It should look like this:

driver.FindElement(By.CssSelector("input[name=\"eventCategoryID\"]")).Click();
driver.FindElement(By.CssSelector("input[value=\"11\"]")).Click();

The \\ escapes the following quotation mark so that it doesn't end the string.

您为什么不尝试XPath

 driver.FindElement(By.Xpath("")).Click();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM