Get HTML Source of WebElement in Selenium WebDriver using Python

后端 未结 14 1980
误落风尘
误落风尘 2020-11-22 13:45

I\'m using the Python bindings to run Selenium WebDriver:

from selenium import webdriver
wd = webdriver.Firefox()

I know I can grab a webel

14条回答
  •  天命终不由人
    2020-11-22 14:21

    I hope this could help: http://selenium.googlecode.com/svn/trunk/docs/api/java/org/openqa/selenium/WebElement.html

    Here is described Java method:

    java.lang.String    getText() 
    

    But unfortunately it's not available in Python. So you can translate the method names to Python from Java and try another logic using present methods without getting the whole page source...

    E.g.

     my_id = elem[0].get_attribute('my-id')
    

提交回复
热议问题