Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Selenium 如何根据日期和时间点击日历?_Selenium_Selenium Webdriver - Fatal编程技术网

Selenium 如何根据日期和时间点击日历?

Selenium 如何根据日期和时间点击日历?,selenium,selenium-webdriver,Selenium,Selenium Webdriver,请检查所附图片以供参考。我想点击特定的一周的日期和时间。我尝试使用Xpath,但总是得到NoSuchElementFoundException 您可以尝试以下方法: driver.FindElement(By.XPath("//div[@class='rc-row rc-widget-header' and /th[contains(.,'Sun 1/22'")]])); //Create a list containing all the elements from the callenda

请检查所附图片以供参考。我想点击特定的一周的日期和时间。我尝试使用Xpath,但总是得到
NoSuchElementFoundException

您可以尝试以下方法:

driver.FindElement(By.XPath("//div[@class='rc-row rc-widget-header' and /th[contains(.,'Sun 1/22'")]]));
//Create a list containing all the elements from the callendar.
IList<WebElement> listOfElements = new IList<WebElement>();
listOfElements = driver.FindElements(By.XPath("//div[@class='rc-row rc-widget-header']/table/thread/tr/th"));
//Search for the one that matches the element that you are looking for.
foreach(IWebElement element in listOfElements){
      if(element.Text.equals("Sun 1/22"){
         element.Click();
      }
}
您也可以尝试以下方法:

driver.FindElement(By.XPath("//div[@class='rc-row rc-widget-header' and /th[contains(.,'Sun 1/22'")]]));
//Create a list containing all the elements from the callendar.
IList<WebElement> listOfElements = new IList<WebElement>();
listOfElements = driver.FindElements(By.XPath("//div[@class='rc-row rc-widget-header']/table/thread/tr/th"));
//Search for the one that matches the element that you are looking for.
foreach(IWebElement element in listOfElements){
      if(element.Text.equals("Sun 1/22"){
         element.Click();
      }
}
//创建一个包含调用者中所有元素的列表。
IList listofements=新IList();
listofements=driver.FindElements(By.XPath(“//div[@class='rc-row-rc-widget header']]/table/thread/tr/th”);
//搜索与要查找的元素匹配的元素。
foreach(元素列表中的IWebElement元素){
if(element.Text.equals(“Sun 1/22”){
元素。单击();
}
}

有些行以24小时格式显示09:00:00或09:15:00的时段。因此,如果您想在上午9点单击Sun 1/22,那么我该如何实现它。您可能需要将“Sun 1/22”更改为您要单击的值,如"Sun 1/22 09:00:00,如果我理解正确。您所指的时间戳是否与屏幕截图上显示的时间戳相同?如果您看到html代码,则有两个不同的代码块,一个用于标题,显示日期,另一个用于显示行中的时间。我猜此表中的日期和时间之间没有关联。请提示。它发布一个清晰简洁的解决方案示例,并给出结果,比发布这样的截图要好。请阅读这里关于如何提出好问题的内容