I use driver like this
import ...
chrome_options = Options()
chrome_options.add_experimental_option("debuggerAddress", "127.0.0.1:9222")
driver = webdriver.Chrome(options=chrome_options)
# then I open target URL in chrome manually
input_element = driver.find_element(By.XPATH, '//textarea')
sometimes it works, but sometimes I can not locate the target element.
Then I try it in debug, after breakpoint, I can see that there is a textarea tag in driver.page_source
, but
driver.find_element(By.XPATH, '//textarea')
still doesn`t work, even
driver.find_element(By.XPATH, '/html')
will return no such element.
I try driver.refresh()
, it works.
I don`t know what happen to the driver
0
It might be that you are evaluating your page before it fully loads. Try some sleep method hooked to the driver instance.
1