6. Selenium Examples For YOu

Hi  friends this is a perfect example of selenium with proxy. Here  are four proxy which We are using alternatively.

from selenium import webdriver
import random
import time
from selenium.webdriver.common.proxy import *

while True:
    proxy = ['123.129.240.173:8081','201.63.184.41:3128','58.1.251.57:80','121.192.190.101:9999']
    myProxy = "http://"+proxy[random.randint(0,3)]
    print myProxy

    proxy = Proxy({
    'proxyType': 'MANUAL',
    'httpProxy': myProxy
  
    })

    driver = webdriver.Firefox(proxy=proxy)
    driver.implicitly_wait(30)
    driver.get("http://autopython.blogspot.in")
    time.sleep(5)
    driver.close()
---------------------------------------------------------------------------------------------------------
Selenium Example for iphone and android

from selenium import webdriver
# iPhone
driver = webdriver.Remote(browser_name="iphone", command_executor='http://172.24.101.36:3001/hub')
# Android
driver = webdriver.Remote(browser_name="android", command_executor='http://127.0.0.1:8080/hub')
# Google Chrome
driver = webdriver.Chrome()
# Firefox
driver = webdriver.Firefox()
# ------------------------------
# The actual test scenario: Test the codepad.org code execution service.
# Go to codepad.org
driver.get('http://codepad.org')
# Select the Python language option
python_link = driver.find_elements_by_xpath("//input[@name='lang' and @value='Python']")[0]
python_link.click()
# Enter some text!
text_area = driver.find_element_by_id('textarea')
text_area.send_keys("print 'Hello,' + ' World!'")
# Submit the form!
submit_button = driver.find_element_by_name('submit')
submit_button.click()
# Make this an actual test. Isn't Python beautiful?
assert "Hello, World!" in driver.get_page_source()
# Close the browser!
driver.quit()

No comments: