如何使用 C# select 从 ajax calendarextender 在 selenium Webdriver 中约会
How to select date in selenium Webdriver from ajax calendarextender using C#
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
您的问题在这里:
if (cell.Equals("13"))
您想访问 IWebElement
的 Text
属性...
if (cell.Text.Equals("13")) .....
这段代码对我有用:)
IWebElement 日期 = driver.FindElement(By.Id("ctl00_masterContentPlaceHolder_CalendarExtender3_daysBody"));
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;
}
}
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
您的问题在这里:
if (cell.Equals("13"))
您想访问 IWebElement
的 Text
属性...
if (cell.Text.Equals("13")) .....
这段代码对我有用:)
IWebElement 日期 = driver.FindElement(By.Id("ctl00_masterContentPlaceHolder_CalendarExtender3_daysBody"));
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;
}
}