ham*_*yad 3 selenium enter submit python-3.x instagram
我想在 Instagram 中搜索一个特殊的关键字。例如,我想搜索这个词:“快餐”。我可以在搜索框中发送此密钥。但是,当我通过 Python3 在 Selenium 中使用 submit 方法时,它不起作用并给我错误。这是我的代码:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.alert import Alert
from selenium.webdriver.support.ui import WebDriverWait as wait
from selenium.webdriver.support import expected_conditions as EC
import time
driver = webdriver.Firefox()
url="https://www.instagram.com/p/pTPI-kyX7g/?tagged=resurant"
driver.get(url)
#login_button=driver.find_element_by_xpath("""/html/body/span/section/main/article/div[2]/div[2]/p/a""")
#login_button.click()
import time
driver.implicitly_wait(5)
search_button=driver.find_element_by_xpath("""/html/body/span/section/nav/div[2]/div/div/div[2]/input""")
search_button.send_keys("fast food")
search_button.submit()
Run Code Online (Sandbox Code Playgroud)
这是错误的:
selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: ./ancestor-or-self::form
Run Code Online (Sandbox Code Playgroud)
你可以帮帮我吗?
代替。submit() 尝试 '.send_keys(u'\ue007')'
请参阅:http : //selenium-python.readthedocs.io/api.html#module-selenium.webdriver.common.keys
| 归档时间: |
|
| 查看次数: |
12206 次 |
| 最近记录: |