IWebElement date = driver.FindElement(By.Id("ctl00_masterContentPlaceHolder_ImgBtnModifiedStart"));
IList<IWebElement> row = date.FindElements(By.TagName("tr"));
IList<IWebElement> col = date.FindElements(By.TagName("td"));
for (IWebElement cell: col)
{
if (cell.Equals("13"))
{
cell.FindElement(By.LinkText("13")).Click();
}
}
Error Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement occured at for loop
答案 0 :(得分:0)
您的问题在这里:
if (cell.Equals("13"))
您想要访问Text
...
IWebElement
属性
if (cell.Text.Equals("13")) .....
答案 1 :(得分:0)
这段代码对我有用:)
IWebElement date = driver.FindElement(By.Id(&#34; ctl00_masterContentPlaceHolder_CalendarExtender3_daysBody&#34;));
IList<IWebElement> row = date.FindElements(By.TagName("tr"));
IList<IWebElement> col = date.FindElements(By.TagName("td"));
foreach (IWebElement cell in col)
{
if (cell.Text.Equals("13"))
{
cell.Click();
break;
}
}