Reverted changes to upload and collection. Issue existed in login/logout. Fixed.
[mediagoblin-automation:mediagoblin-selenium.git] / tests / util / login.py
1 '''
2    Copyright 2013 Emily O'Leary
3
4    Licensed under the Apache License, Version 2.0 (the "License");
5    you may not use this file except in compliance with the License.
6    You may obtain a copy of the License at
7
8        http://www.apache.org/licenses/LICENSE-2.0
9
10    Unless required by applicable law or agreed to in writing, software
11    distributed under the License is distributed on an "AS IS" BASIS,
12    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13    See the License for the specific language governing permissions and
14    limitations under the License.
15 '''
16 import util
17 from selenium import webdriver
18 from selenium.webdriver.common.by import By
19 from selenium.webdriver.support.ui import Select
20 from selenium.common.exceptions import NoSuchElementException
21 import unittest, time, re
22
23 class Login():
24     def log_in(self, external, data):
25         self.driver = external.driver
26         self.driver.implicitly_wait(30)
27         self.base_url = external.base_url
28         self.verificationErrors = []
29         self.accept_next_alert = True
30         testharness = unittest.FunctionTestCase(self)
31         driver = self.driver
32         driver.get(self.base_url + "/")
33         driver.find_element_by_link_text("Log in").click()
34         driver.find_element_by_id("username").clear()
35         driver.find_element_by_id("username").send_keys(data["username"])
36         driver.find_element_by_id("password").clear()
37         driver.find_element_by_id("password").send_keys(data["password"])
38         # Warning: verifyTextPresent may require manual changes
39         try: testharness.assertRegexpMatches(driver.find_element_by_css_selector("BODY").text, r"^[\s\S]*Log in[\s\S]*$")
40         except AssertionError as e: self.verificationErrors.append(str(e))
41         testharness.assertTrue(util.is_element_present(self,By.ID, "username"))
42         testharness.assertTrue(util.is_element_present(self,By.ID, "password"))
43         driver.find_element_by_css_selector("input.button_form").click()
44         driver.find_element_by_css_selector("div.button_action.header_dropdown_down").click()
45         testharness.assertTrue(util.is_element_present(self,By.LINK_TEXT, data["username"]))
46