Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Как мы заставили роботов тестировать

Как мы заставили роботов тестировать

Про автоматизацию тестирования веб-приложений

Paul Stashevsky

October 05, 2013
Tweet

More Decks by Paul Stashevsky

Other Decks in Programming

Transcript

  1. Как установить? 1. Устанавливаем java, если еще не стоит. 2.

    Скачиваем selenium webdriver http://selenium.googlecode.com/files/selenium- server-standalone-2.35.0.jar 3. Запускаем java -jar selenium-server.jar
  2. Что под капотом? Python, Ruby, Java, C#, JavaScript, PHP, ...

    Selenium webdriver Your awesome App API HTTP HTTP
  3. from selenium import webdriver from selenium.common.exceptions import TimeoutException from selenium.webdriver.support.ui

    import WebDriverWait from selenium.webdriver.support import expected_conditions as EC driver = webdriver.Firefox() driver.get("http://www.google.com") inputElement = driver.find_element_by_name("q") inputElement.send_keys("cheese!") inputElement.submit() print driver.title try: WebDriverWait(driver, 10).until(EC.title_contains("cheese!")) print driver.title finally: driver.quit()
  4. from selenium import webdriver from selenium.common.exceptions import TimeoutException from selenium.webdriver.support.ui

    import WebDriverWait from selenium.webdriver.support import expected_conditions as EC driver = webdriver.Firefox() driver.get("http://2gis.ru") inputElement = driver.find_element_by_id("search-what") inputElement.send_keys("IKEA") inputElement.submit() print driver.title driver.quit()
  5. import unittest from selenium import webdriver from selenium.webdriver.common.keys import Keys

    class PythonOrgSearch(unittest.TestCase): def setUp(self): self.driver = webdriver.Firefox() def test_search_in_python_org(self): driver = self.driver driver.get("http://www.python.org") self.assertIn("Python", driver.title) elem = driver.find_element_by_name("q") elem.send_keys("selenium") elem.send_keys(Keys.RETURN) self.assertIn("Google", driver.title) def tearDown(self): self.driver.close() if __name__ == "__main__": unittest.main()
  6. Для чего нужен unittest? 1. Сделать тест-кейс (TestCase) 2. Cделать

    предусловия и постусловия (setUp, tearDown) 3. Добавить в тест проверки (assert)