Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/365.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和pytest(python)中访问日期选择器_Python_Selenium_Automation - Fatal编程技术网

如何在selenium和pytest(python)中访问日期选择器

如何在selenium和pytest(python)中访问日期选择器,python,selenium,automation,Python,Selenium,Automation,我正在用python进行自动化测试selenium,我被困在这里了。我无法点击日期。请帮我获取代码,点击日期 enter code here #day driver.find_element(By.XPATH("//span[@class='flatpickr-day' and text()='4']")).click() time.sleep(10) 首先,您需要获取具有所需日期的对象,您可以使用XPath: //span[@class="

我正在用python进行自动化测试selenium,我被困在这里了。我无法点击日期。请帮我获取代码,点击日期

enter code here
    #day
    driver.find_element(By.XPATH("//span[@class='flatpickr-day' and text()='4']")).click()
    time.sleep(10)

首先,您需要获取具有所需日期的对象,您可以使用XPath:

//span[@class="flatpickr-day" and text()="4"]
此XPath将选择日期为8月4日的范围

然后用Selenium/Java编写代码:

driver.findElement(By.xpath("//span[@class='flatpickr-day' and text()='4']")).Click();

欢迎来到SO!请提供您已经尝试的代码和详细信息以及错误消息(如果有)。还请避免发布代码/错误消息等截图。用python复制粘贴这些截图。selenium,为什么要标记Java?