简体   繁体   中英

Python Selenium - NoSuchElementException. Why do I keep getting this?

I am trying to paste values into a form using Selenium in Python, but I keep getting NoSuchElementException as shown in the picture below.

I tried various find_element_by_xx but keep getting the same error. Can anyone advise what I am doing wrong?

The form I'm filling in is a custom querying Cognos report. The ID is visible of the block (shown in the pic below), but it does not seem to be working.

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
browser = webdriver.Chrome()
browser.get("website") #"website" is placeholder
elem = browser.find_element_by_id("PRMT_TB_N0000000016B521C0x000000002552DDD8_NS_")
elem.send_keys(Keys.CONTROL,'v') 

Form :

表单 ID

Code:

代码

Exception:

例外

I figured it out.

Copy Full Xpath when inspecting the element and use find_element_by_xpath.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM