Wednesday, September 23, 2015

Simple selenium with python example

'''
Created on Sep 22, 2015

@author: Prashant Chauhan

'''

from selenium import webdriver
from selenium.webdriver.common.keys import Keys

driver = webdriver.Firefox()
driver.get('http://www.python.org')
assert "Python" in driver.title
elem = driver.find_element_by_name("q")
elem.send_keys("pycon")
elem.send_keys(Keys.RETURN)
assert "No results found." not in driver.page_source
driver.close()

Python setup with selenium in eclipse

22092015

1. Install Eclipse any version.
2. Download and install JDK 7 or later
3. Download and install Python 2.7 or 3.5
4. Download the Selenium-2.47.3-py2-none-any.whl
5. Set the path for Java and Python Like :
    a. C:\python27\scripts
    b. %JAVA_HOME%/bin
6. Open command prompt and run :
    pip install -U selenium
7. Then you can see the result install selenium successfully the go further.
8. Install some more software in eclipse like:
    a. PyDev and PyDev Extension
    b. http://pydev.org/updates
    Then
    i: Trust the certificate.
    ii: Restart the eclipse
9: Now set the interpreter to the eclipse for creating projects.

10. Please run the simple program and enjoy.

Thanks:
Prashant Chauhan