Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/321.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
在单击使用python和selenium之前,如何使用wait expected condition等待元素中的属性包含特定值_Python_Selenium_Selenium Webdriver_Xpath_Webdriverwait - Fatal编程技术网

在单击使用python和selenium之前,如何使用wait expected condition等待元素中的属性包含特定值

在单击使用python和selenium之前,如何使用wait expected condition等待元素中的属性包含特定值,python,selenium,selenium-webdriver,xpath,webdriverwait,Python,Selenium,Selenium Webdriver,Xpath,Webdriverwait,请尝试使用等待条件等待一个元素的值更改,然后单击它 这是以前的代码 driver.find_elements_by_xpath('//div[@data-markettypecategory="00000000-0000-0000-da7a-000000580001" and @data-pd="12.01"]')[0].click() 上面的代码只在data pd=12.01时有效,我想让它等待data pd是price(例如$12.01),它可以是

请尝试使用等待条件等待一个元素的值更改,然后单击它

这是以前的代码

 driver.find_elements_by_xpath('//div[@data-markettypecategory="00000000-0000-0000-da7a-000000580001" and @data-pd="12.01"]')[0].click()

上面的代码只在data pd=12.01时有效,我想让它等待data pd是price(例如$12.01),它可以是任何值(例如100.00,2.00,50.00 e.t.c),我只想它能够等到值变为12.01,直到它单击首先,复制FULLXpath普通Xpath

完整XPath如下所示:

xpath = '/html/body/div[3]/div[2]/div/div[1]/div[1]/h1/a'
然后可以获取元素的文本值,并检查它是否更改

string = driver.find_elements_by_xpath(xpath).text
print(string)
if string == "12.01":
   click()