M
M
Mark Adams2016-06-07 17:47:09
Python
Mark Adams, 2016-06-07 17:47:09

How to get current html data after click() method in Selenium?

I can connect and follow the link:

from selenium import web driver

driver = webdriver.Firefox()
driver.get("https://www.example.com")
driver.find_element_by_xpath("/html/body/div...]").click()

How to get html from the new page (which was clicked)?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
Y
YaroslavS, 2016-06-07
@ilyakmet

Perhaps the problem is that the data did not have time to load
About waiting, read here about waiting
I did something like this

from selenium import webdriver
import selenium.webdriver.support.ui as ui

browser = webdriver.Firefox()
wait = ui.WebDriverWait(browser,30)
browser.execute_script('')#скрипт осуществлял переход на другую страницу в моем случае так в вашем по другому (driver.find_element_by_xpath("/html/body/div...]").click())
wait.until(lambda browser: browser.find_element_by_id('someID'))
some_info = browser.find_element_by_id('someID').get_attribute("outerHTML")

M
Mark Adams, 2016-06-07
@ilyakmet

Found this: How to get Selenium to wait for page load after a click , but haven't figured it out yet.

V
Vyacheslav, 2016-06-07
@Firik67

driver.current_url?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question