Tuesday, 18 March 2014

How to find the elements by tag name in Selenium Webdriver in Python?


We can identify any element in the web page with given tag. 

Example – Suppose you want to enter the data in the first input tag element. 


from selenium import webdriver

#driver = webdriver.Chrome("F:\\selenium\\Csharp\\iedriverserver.exe")

#driver = webdriver.Chrome("F:\\selenium\\Csharp\\chromedriver.exe")

driver = webdriver.Firefox()

driver.get("http://register.rediff.com/register/register.php")

try:

  firstinput = element.find_elements_by_tag_name("input")

  firstinput.send_keys("input-data")

  driver.close()

except Exception as e:

    print ("Exception occured", format(e));

finally:

    driver.quit()

    print ("finally")


What do you think on above selenium topic. Please provide your inputs and comments. You can write to me at reply2sagar@gmail.com

No comments:

Post a Comment

Buy Best Selenium Books

About Me

My photo

Self-motivated software professional