e2e_test.py 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. from selenium import webdriver
  2. capabilities = webdriver.DesiredCapabilities.CHROME.copy()
  3. WD_URL = 'http://localhost:8001'
  4. driver = webdriver.Remote(desired_capabilities=capabilities, command_executor=WD_URL)
  5. print "Loading angularjs.org"
  6. driver.get('https://angularjs.org/')
  7. print "Testing hello app"
  8. sample_app = driver.find_element_by_css_selector("[app-run='hello.html']")
  9. sample_app.location_once_scrolled_into_view
  10. name_box = sample_app.find_element_by_css_selector('[ng-model="yourName"]')
  11. hello_box = sample_app.find_element_by_css_selector('h1')
  12. name_box.send_keys('Bob')
  13. assert "Hello Bob!" in hello_box.text
  14. print "Testing todo app"
  15. todo_app = driver.find_element_by_css_selector("[app-run='todo.html']")
  16. todo_app.location_once_scrolled_into_view
  17. todo_input = todo_app.find_element_by_css_selector('[ng-model="todoList.todoText"]')
  18. todo_list = todo_app.find_element_by_css_selector('ul')
  19. todo_input.send_keys('write some tests');
  20. add_button = todo_app.find_element_by_css_selector('[value="add"]')
  21. add_button.click()
  22. assert 'write some tests' in todo_list.text