因此,我正在关注有关YouTube机器人的YouTube教程(https://www.youtube.com/watch?v=BGU2X5lrz9M),但它始终会给我错误
Unable to locate element:
我无法弄清楚出了什么问题,发现的所有问题都表明我可以切换到frame或iframe,但是本教程中的人不必这么做,而且我也无法弄清楚该怎么做。开关。请帮帮我!
这是代码
driver = self.driver
driver.get('https://www.instagram.com/')
time.sleep(2)
login_button = driver.find_element_by_xpath('//*[@id="react-root"]/section/main/article/div[2]/div[2]/p/a')
login_button.click()
time.sleep(2)
username_elem = driver.find_element_by_xpath('//*[@id="f2fdc3b5774d3f4"]')
username_elem.clear()
username_elem.send_keys(self.username)
password_elem = driver.find_element_by_xpath('//*[@id="f25923ff3b40138"]')
password_elem.clear()
password_elem.send_keys(self.password)
password_elem.send_keys(Keys.RETURN)
time.sleep(2)
答案 0 :(得分:0)
与框架无关,但输入形式的元素ID
已更改
选择by name
driver.get('https://www.instagram.com/')
login_button = driver.find_element_by_link_text('Log in')
login_button.click()
time.sleep(2)
username_elem = driver.find_element_by_name('username')
username_elem.clear()
username_elem.send_keys(self.username)
password_elem = driver.find_element_by_name('password')
password_elem.clear()
password_elem.send_keys(self.password)
password_elem.send_keys(Keys.RETURN)
time.sleep(2)