Skip to content
This repository has been archived by the owner on Feb 28, 2022. It is now read-only.

Commit

Permalink
Fixing deleting a group test
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrei Hutusoru authored and Andrei Hutusoru committed Mar 11, 2014
1 parent 9daad33 commit 77766e8
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 32 deletions.
4 changes: 2 additions & 2 deletions pages/edit_profile.py
Expand Up @@ -10,7 +10,7 @@
import random
from pages.base import Base
from pages.profile import Profile
from pages.group_page import GroupPage
from pages.groups_page import GroupsPage
from selenium.webdriver.common.keys import Keys


Expand Down Expand Up @@ -49,7 +49,7 @@ def click_cancel_button(self):

def click_find_group_link(self):
self.selenium.find_element(*self._find_group_page).click()
return GroupPage(self.testsetup)
return GroupsPage(self.testsetup)

def set_full_name(self, full_name):
element = self.selenium.find_element(*self._full_name_field_locator)
Expand Down
12 changes: 7 additions & 5 deletions pages/group_info_page.py
Expand Up @@ -6,13 +6,15 @@


from selenium.webdriver.common.by import By

from pages.base import Base


class GroupInfoPage(Base):
_delete_group_button = (By.ID, 'delete-group')

_delete_group_button = (By.CSS_SELECTOR, '.button.delete.right')

def delete_group(self):
self.selenium.find_element(*self._delete_group_button).click()
from pages.group_page import GroupPage
return GroupPage(self.testsetup)
from pages.groups_page import GroupsPage
return GroupsPage(self.testsetup)
19 changes: 0 additions & 19 deletions pages/group_page.py

This file was deleted.

42 changes: 42 additions & 0 deletions pages/page.py
Expand Up @@ -4,11 +4,14 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

import time

from unittestzero import Assert

from selenium.webdriver.support.ui import WebDriverWait
from selenium.common.exceptions import WebDriverException
from selenium.common.exceptions import NoSuchElementException
from selenium.common.exceptions import TimeoutException
from selenium.common.exceptions import ElementNotVisibleException


Expand Down Expand Up @@ -61,6 +64,45 @@ def is_element_present(self, *locator):
# set back to where you once belonged
self.selenium.implicitly_wait(self.testsetup.default_implicit_wait)

def wait_for_element_visible(self, *locator):
count = 0
while not self.is_element_visible(*locator):
time.sleep(1)
count += 1
if count == self.timeout:
raise Exception(':'.join(locator) + " is not visible")

def wait_for_element_not_visible(self, *locator):
count = 0
while self.is_element_visible(*locator):
time.sleep(1)
count += 1
if count == self.timeout:
raise Exception(':'.join(locator) + " is still visible")

def wait_for_element_present(self, *locator):
"""Wait for an element to become present."""
self.selenium.implicitly_wait(0)
try:
WebDriverWait(self.selenium, 10).until(lambda s: self._selenium_root.find_element(*locator))
except TimeoutException:
Assert.fail(TimeoutException)
finally:
# set back to where you once belonged
self.selenium.implicitly_wait(self.testsetup.default_implicit_wait)

def wait_for_element_not_present(self, *locator):
"""Wait for an element to become not present."""
self.selenium.implicitly_wait(0)
try:
WebDriverWait(self.selenium, 10).until(lambda s: len(self._selenium_root.find_elements(*locator)) < 1)
return True
except TimeoutException:
return False
finally:
# set back to where you once belonged
self.selenium.implicitly_wait(self.testsetup.default_implicit_wait)

def is_element_visible(self, *locator):
try:
return self._selenium_root.find_element(*locator).is_displayed()
Expand Down
15 changes: 9 additions & 6 deletions tests/test_profile.py
Expand Up @@ -297,20 +297,23 @@ def test_that_non_US_user_can_set_get_involved_date(self, mozwebqa):
def test_that_user_can_create_and_delete_group(self, mozwebqa):
current_time = time.strftime("%x"+"-"+"%X")
group_name = ('qa_test' + ' ' + current_time)

home_page = Home(mozwebqa)
home_page.login()
edit_page = home_page.header.click_edit_profile_menu_item()
groups = edit_page.click_find_group_link()
create_group = groups.click_create_group_main_button()
create_group.create_group_name(group_name)
create_group.click_create_group_submit()

search_listings = create_group.header.search_for(group_name)

Assert.true(search_listings.is_element_present(By.LINK_TEXT, group_name))

group_info = search_listings.open_group(group_name)
search_listings = group_info.delete_group()

groups_page = group_info.delete_group()
groups_page.wait_for_alert_message()

home_page.header.click_edit_profile_menu_item()

Assert.false(search_listings.is_element_present(By.LINK_TEXT, group_name))

0 comments on commit 77766e8

Please sign in to comment.