Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/289.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

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 python wait不';行不通_Python_Selenium_Firefox - Fatal编程技术网

selenium python wait不';行不通

selenium python wait不';行不通,python,selenium,firefox,Python,Selenium,Firefox,我试过这个 WebDriverWait(web.driver,1000000000000000000000000000000000000000000000000) 它什么也没做,什么都没做 web也在动态地改变,新的元素被引入其中,代码不存在于新元素的页面和源代码中 请帮帮我,我整个上午都在忙这个 我在用geckodriver做firefox python 3 测试代码 _browser_profile = webdriver.FirefoxProfile() _browser_profile

我试过这个

WebDriverWait(web.driver,1000000000000000000000000000000000000000000000000)
它什么也没做,什么都没做

web也在动态地改变,新的元素被引入其中,代码不存在于新元素的页面和源代码中

请帮帮我,我整个上午都在忙这个

我在用geckodriver做firefox python 3

测试代码

_browser_profile = webdriver.FirefoxProfile()
_browser_profile.set_preference("dom.webnotifications.enabled", False)
driver=webdriver.Firefox(firefox_profile= _browser_profile)
driver.get("https://www.google.com/")
wait= WebDriverWait(driver,10)
driver.get("https://www.youtube.com")

这只是显式等待的声明

如果您不将其与符合预期条件的EC绑定,则此操作将不起任何作用
WebDriverWait(web.driver,10000000000000000000000000000000000000000000000000000000000)

你必须这样做:

wait = WebDriverWait(driver, 10)
element = wait.until(EC.element_to_be_clickable((By.ID, 'someid')))  
有关显式等待的更多信息,请访问

更新:

对于共享的代码,您只是让脚本知道它有显式等待

您根本没有使用显式等待

driver.get("https://www.google.com/")
search_bar = wait.until(EC.element_to_be_clickable((By.NAME, 'q')))
search_bar.sendkeys("Hi Google")
请注意,您必须导入以下内容:

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC  

我不知道为什么@Andrei为你提供了最糟糕的显式等待,那就是时间。睡眠(10),应该尽量避免。如果你提供一个链接到该页面,那就太好了,或者相关的html,还有你得到的错误和你得到的代码片段。问题是我没有得到任何错误。我将提供代码。函数的可能副本在selenium中无法正常工作。这就是我的问题,为什么这个代码不起作用。遗憾的是,任何等待函数都不适用于我,即使是你引用的站点中的代码。遗憾的是,好像没有等待在等待。对不起,我没有理解你。在哪里没有写等待?就好像我没有写等待=WebDriverWait(driver,10),我不知道,但我认为这是软件的问题,不是代码的问题。我最初在等待之前使用了该代码,但它不起作用,所以我试着看看问题在哪里,发现等待不起作用。。在这一点上,我真的非常渴望找到一个解决方案,任何能让它工作的东西:\。向下滚动,直到出现一个元素,然后使用一些正则表达式将其提取出来,并以文本形式打印。。我做了所有的事情。奇怪的是,当我向下滚动并询问page_源代码时,我只得到了旧的html。我还试图通过命令找到元素,但没有源代码,但驱动程序仍然不知道。