Monday, 17 March 2014

Identifying the elements with ID in Selenium Webdriver in Python

If you know the id of particular element, then you can easily identify it in Selenium Webdriver.
Below example will illustrate how we can identify the web elements using Selenium Webdriver in Python.

Below example will enter 9850 in the textbox having id - mobno

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:
   driver.find_element_by_id("mobno").send_keys("9850")
   
   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

Contributors