Advertisement
Guest User

Untitled

a guest
Jun 21st, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. # To install the Python client library:
  2. # pip install -U selenium
  3.  
  4. # Import the Selenium 2 namespace (aka "webdriver")
  5. from selenium import webdriver
  6. from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
  7. from selenium.webdriver.common.by import By
  8.  
  9. # Remote
  10. driver = webdriver.Remote(command_executor='http://driver:4444/wd/hub', desired_capabilities=DesiredCapabilities.CHROME)
  11.  
  12. # ------------------------------
  13. # The actual test scenario: Test the codepad.org code execution service.
  14.  
  15. driver.get('http://thedemosite.co.uk/login.php')
  16.  
  17. # Select the Python language option
  18. #python_link = driver.find_elements_by_xpath("//input[@name='lang' and @value='Python']")[0]
  19. #python_link.click()
  20.  
  21. # Enter some text!
  22. username = driver.find_element_by_name('username')
  23. username.send_keys("admin")
  24.  
  25. password = driver.find_element_by_name('password')
  26. password.send_keys("admin")
  27.  
  28. # Submit the form!
  29. submit_button = driver.find_element_by_name('FormsButton2')
  30. submit_button.click()
  31.  
  32. for line in driver.page_source():
  33. print line
  34.  
  35. # Make this an actual test. Isn't Python beautiful?
  36. assert "Successful Login" in driver.page_source()
  37.  
  38. # Close the browser!
  39. driver.quit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement