image = driver.find_element_by_id('url-upload-input').send_keys('https://images.pexels.com/photos/67636/rose-blue-flower-rose-blooms-67636.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940')
time.sleep(20)
image_upload = driver.find_element_by_id("url-uploaded-preview-img")
driver.execute_script("arguments[0].click();", image_upload)
我遇到此错误,我可能知道如何从URL上传图像
Traceback (most recent call last):
File "F:/automation/check.py", line 38, in <module>
image = driver.find_element_by_id('url-upload-input').send_keys('https://images.pexels.com/photos/67636/rose-blue-flower-rose-blooms-67636.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940')
File "F:\automation\venv\lib\site-packages\selenium\webdriver\remote\webelement.py", line 479, in send_keys
'value': keys_to_typing(value)})
File "F:\automation\venv\lib\site-packages\selenium\webdriver\remote\webelement.py", line 633, in _execute
return self._parent.execute(command, params)
File "F:\automation\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "F:\automation\venv\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.ElementNotVisibleException: Message: element not visible
答案 0 :(得分:0)
尝试等待元素可见:
WebDriverWait(driver, 30).until(
EC.visibility_of_element_located((By.ID, "url-uploaded-preview-img"))
)