seitime-frappe/frappe/docs/user/en/guides/automated-testing/integration-testing.md
Rushabh Mehta f409fd7358 [ui-tests] python is back! (#3565)
* [ui-tests] python is back!

* [minor] remove old test

* [test] dont test test_runner

* [tests] try firefox

* [tests] try chrome

* [tests] try chrome

* [tests] try chrome

* [tests] try chrome 1

* [tests] try chrome 2

* [tests] try chrome 3

* [tests] try phantomJS

* [tests] try chrome

* [tests] try chrome

* [tests] try chrome

* [tests] try chrome

* [tests] try chrome

* [tests] try chrome

* [tests] try chrome

* [tests] try chrome

* [tests] login click button

* [tests] login click button

* [tests] show log

* [test] test with start_maximized

* [test] test only login

* [travis] test another port for selenium

* [travis] try running ui tests after unittests are done

* [travis] pring body_div if fails

* [tests] complete setup wizard for frappe

* [minor] move ui tests to frappe/ui/tests

* [tests] ui tests in public and codacy fixes

* [fix] tests + eslint

* [minor] move tests to tests/ui folder and print console after print

* [fix] linting

* [tests] added documentation and better integration testing

* [promise] form triggering is now promise based

* [test]

* [test]

* [test]

* [test]

* [test] print output

* [minor] default empty in select and print console

* [cleanup] more minor fixes

* [enhance] first-cut done!

* [minor] frappe.run_serially to pass arguments while chaining
2017-07-03 11:53:00 +05:30

1.2 KiB

UI Integration Testing

You can write integration tests using the Selenium Driver. frappe.utils.selenium_driver gives you a friendly API to write selenium based tests

To write integration tests, create a standard test case by creating a python file starting with test_

All integration tests will be run at the end of the unittests.

Example

Here is an example of an integration test to check insertion of a To Do

from __future__ import print_function
from frappe.utils.selenium_testdriver import TestDriver
import unittest
import time

class TestToDo(unittest.TestCase):
	def setUp(self):
		self.driver = TestDriver()

	def test_todo(self):
		self.driver.login()

		# list view
		self.driver.set_route('List', 'ToDo')

		time.sleep(2)

		# new
		self.driver.click_primary_action()

		time.sleep(2)

		# set input
		self.driver.set_text_editor('description', 'hello')

		# save
		self.driver.click_modal_primary_action()

		time.sleep(2)

		self.assertTrue(self.driver.get_visible_element('.result-list')
			.find_element_by_css_selector('.list-item')
			.find_element_by_css_selector('.list-id').text=='hello')

	def tearDown(self):
		self.driver.close()