1 ------------------------
2 How to Contribute Tests
3 ------------------------
4 Tests can be recorded using Selenium IDE within Firefox or by generating the
5 HTML either programmatically or by hand. Theses tests are then to be added
6 to the TestSuite.html under tests/src.
8 The current workflow then requires that you export your test case as a
9 "Python 2 webdriver" script and save it in the tests/ folder. In the future
10 this conversion will be done by the automation framework itself so only the
11 HTML source file will need to be committed.
13 ------------------------
15 ------------------------
16 Don't set your base url to have a forward slash at the end. Selenium adds the forward
17 slash for you by default.
19 The Selenium IDE doesn't currently export the selection of dropdown items, instead
20 it throws the following error:
21 # ERROR: Caught exception [ReferenceError: selectLocator is not defined]
23 Here is an example of one wayto add a dropdown selection to a script:
24 select = Select(driver.find_element_by_id("license"))
25 select.select_by_visible_text("CC0 1.0")
27 ------------------------
29 ------------------------
30 If a test makes use of local files, such as those found under the resources
31 directory, you need to edit the Selenium HTML file and replace the your specific
32 base directory path with the parameter WORKING_DIRECTORY.
35 /home/lotusecho/gmg/mediagoblin-selenium/resources/gavroche.png
39 WORKING_DIRECTORY/resources/gavroche.png
41 When runtests.sh is run it will process that paramter and replace it with your
42 current working directory.
44 ------------------------
45 When Recording / Code Reuse
46 ------------------------
47 At /tests/util we have provided a small set of often-used functions that can be
48 added to your test cases to reduce the amount of repeated work.
50 When you record your tests you don't need to record the login/logout steps as
51 a part of test. Instead, add them to the exported python file.
53 ------------------------
55 ------------------------
56 Add this -> from util import login, logout
57 Right before -> from selenium import webdriver
61 Next, find your test function, like the following:
63 def test_upload_j_p_e_g(self):
65 #Insert your objects here for login
66 data = {"username" : "testuser", "password" : "TestPassworD!"}
67 tLogin = login.LogIn()
68 tLogin.log_in(self, data)
72 Each reusable object takes data from your current test to proceed.