【发布时间】:2021-07-02 05:25:49
【问题描述】:
PFB 我在 Tumblr 上的 Autopost 代码请更正我的 28 号。线
from selenium import webdriver
import pyautogui
import time
email = "Email"
passwd = "Password"
PATH = "C:\Program Files (x86)\chromedriver.exe"
driver = webdriver.Chrome(PATH)
driver.maximize_window()
time.sleep(2)
driver.get("https://www.tumblr.com/login")
time.sleep(2)
driver.find_elements_by_xpath('//*[@id="base-container"]/div[2]/div/div[2]/div/section/div/form/input')
pyautogui.typewrite(email)
time.sleep(1)
pyautogui.press("Enter")
time.sleep(1)
pyautogui.typewrite(passwd)
time.sleep(2)
pyautogui.press("Enter")
time.sleep(4)
driver.find_element_by_xpath('//*[@id="base-container"]/div[2]/div[2]/div[1]/main/div[3]/ul/li[2]/button/span').click()
time.sleep(3)
driver.find_element_by_xpath('//*[@id="row-0"]/div/div/div[1]/button[1]/span/input').click()
time.sleep(5)
下一行有错误-
driver.find_element_by_xpath('//*[@id="row-0"]/div/div/div[1]/button[1]/span/input').click()
也许 iframe 没有定义,请任何人给我你的想法。
【问题讨论】:
-
你遇到了什么错误?
-
selenium.common.exceptions.NoSuchElementException: 消息:没有这样的元素:无法找到元素:{"method":"xpath","selector":"//*[@id="row -0"]/div/div/div[1]/button[1]/span/input"}(会话信息:chrome=89.0.4389.114)
-
@RamDayal : 请将输入元素的相关 HTML 连同父标签一起发布。
-
你能试试这个吗?
img_upload = driver.find_element_by_xpath("//input[@type='file'][@name='photo']")img_upload.send_keys("C:\\Users\\Pictures\\Logo.jpg") -
@Madhan:我面临以下错误 -selenium.common.exceptions.NoSuchElementException:消息:没有这样的元素:无法找到元素:{“method”:“xpath”,“selector”:” //输入[@type='file'][@name='photo']"}(会话信息:chrome=89.0.4389.114)
标签: python python-3.x selenium automation