test_remove_user_from_group_chat added as a part of test_group_chat_send_receive_messages_and_remove_user
This commit is contained in:
parent
a85929e72d
commit
debd51bfce
|
@ -38,7 +38,7 @@ class AbstractTestCase:
|
||||||
desired_caps['deviceOrientation'] = "portrait"
|
desired_caps['deviceOrientation'] = "portrait"
|
||||||
desired_caps['name'] = tests_data.name
|
desired_caps['name'] = tests_data.name
|
||||||
desired_caps['build'] = pytest.config.getoption('build')
|
desired_caps['build'] = pytest.config.getoption('build')
|
||||||
desired_caps['idleTimeout'] = 800
|
desired_caps['idleTimeout'] = 1000
|
||||||
return desired_caps
|
return desired_caps
|
||||||
|
|
||||||
def get_public_url(self, driver):
|
def get_public_url(self, driver):
|
||||||
|
@ -80,7 +80,7 @@ class SingleDeviceTestCase(AbstractTestCase):
|
||||||
def setup_method(self, method):
|
def setup_method(self, method):
|
||||||
self.driver = webdriver.Remote(self.executor_sauce_lab,
|
self.driver = webdriver.Remote(self.executor_sauce_lab,
|
||||||
self.capabilities_sauce_lab)
|
self.capabilities_sauce_lab)
|
||||||
self.driver.implicitly_wait(30)
|
self.driver.implicitly_wait(20)
|
||||||
|
|
||||||
def teardown_method(self, method):
|
def teardown_method(self, method):
|
||||||
self.print_sauce_lab_info(self.driver)
|
self.print_sauce_lab_info(self.driver)
|
||||||
|
@ -89,19 +89,25 @@ class SingleDeviceTestCase(AbstractTestCase):
|
||||||
|
|
||||||
class MultiplyDeviceTestCase(AbstractTestCase):
|
class MultiplyDeviceTestCase(AbstractTestCase):
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def setup_class(cls):
|
||||||
|
cls.loop = asyncio.get_event_loop()
|
||||||
|
|
||||||
def setup_method(self, method):
|
def setup_method(self, method):
|
||||||
|
|
||||||
loop = asyncio.get_event_loop()
|
|
||||||
self.driver_1, \
|
self.driver_1, \
|
||||||
self.driver_2 = loop.run_until_complete(start_threads(2,
|
self.driver_2 = self.loop.run_until_complete(start_threads(2,
|
||||||
webdriver.Remote,
|
webdriver.Remote,
|
||||||
self.executor_sauce_lab,
|
self.executor_sauce_lab,
|
||||||
self.capabilities_sauce_lab))
|
self.capabilities_sauce_lab))
|
||||||
loop.close()
|
|
||||||
for driver in self.driver_1, self.driver_2:
|
for driver in self.driver_1, self.driver_2:
|
||||||
driver.implicitly_wait(30)
|
driver.implicitly_wait(20)
|
||||||
|
|
||||||
def teardown_method(self, method):
|
def teardown_method(self, method):
|
||||||
for driver in self.driver_1, self.driver_2:
|
for driver in self.driver_1, self.driver_2:
|
||||||
self.print_sauce_lab_info(driver)
|
self.print_sauce_lab_info(driver)
|
||||||
driver.quit()
|
driver.quit()
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def teardown_class(cls):
|
||||||
|
cls.loop.close()
|
||||||
|
|
|
@ -7,4 +7,4 @@ def set_password_as_new_user(*args):
|
||||||
view.confirm()
|
view.confirm()
|
||||||
view.type_message_edit_box.send_keys("qwerty1234")
|
view.type_message_edit_box.send_keys("qwerty1234")
|
||||||
view.confirm()
|
view.confirm()
|
||||||
view.find_text("Tap here to enter your phone number & I\'ll find your friends")
|
view.find_full_text("Tap here to enter your phone number & I\'ll find your friends")
|
||||||
|
|
|
@ -2,7 +2,6 @@ import pytest
|
||||||
from tests.basetestcase import MultiplyDeviceTestCase
|
from tests.basetestcase import MultiplyDeviceTestCase
|
||||||
from tests.preconditions import set_password_as_new_user
|
from tests.preconditions import set_password_as_new_user
|
||||||
from views.home import HomeView
|
from views.home import HomeView
|
||||||
from views.base_view import ElementByName
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.sanity
|
@pytest.mark.sanity
|
||||||
|
@ -35,13 +34,13 @@ class TestChats(MultiplyDeviceTestCase):
|
||||||
chats_d2.send_message_button.click()
|
chats_d2.send_message_button.click()
|
||||||
|
|
||||||
chats_d1.back_button.click()
|
chats_d1.back_button.click()
|
||||||
chats_d1.find_text(message_1)
|
chats_d1.find_full_text(message_1)
|
||||||
|
one_to_one_chat_d1 = chats_d1.element_by_text(message_1, 'button')
|
||||||
|
one_to_one_chat_d1.click()
|
||||||
|
|
||||||
one_to_one_chat_d2 = ElementByName(self.driver_2, user_d1_name)
|
one_to_one_chat_d2 = chats_d2.element_by_text(user_d1_name, 'button')
|
||||||
one_to_one_chat_d2.click()
|
one_to_one_chat_d2.click()
|
||||||
chats_d2.chat_message_input.send_keys(message_2)
|
chats_d2.chat_message_input.send_keys(message_2)
|
||||||
chats_d2.send_message_button.click()
|
chats_d2.send_message_button.click()
|
||||||
|
|
||||||
one_to_one_chat_d1 = ElementByName(self.driver_1, message_2)
|
chats_d1.find_full_text(message_2)
|
||||||
one_to_one_chat_d1.click()
|
|
||||||
chats_d1.find_text(message_2)
|
|
||||||
|
|
|
@ -2,16 +2,17 @@ import pytest
|
||||||
from tests.basetestcase import MultiplyDeviceTestCase
|
from tests.basetestcase import MultiplyDeviceTestCase
|
||||||
from tests.preconditions import set_password_as_new_user
|
from tests.preconditions import set_password_as_new_user
|
||||||
from views.home import HomeView
|
from views.home import HomeView
|
||||||
from views.base_view import ElementByName
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.sanity
|
@pytest.mark.sanity
|
||||||
class TestGroupChats(MultiplyDeviceTestCase):
|
class TestGroupChats(MultiplyDeviceTestCase):
|
||||||
|
|
||||||
def test_group_chat(self):
|
def test_group_chat_send_receive_messages_and_remove_user(self):
|
||||||
|
|
||||||
device_1, device_2 = HomeView(self.driver_1), \
|
device_1, device_2 = HomeView(self.driver_1), \
|
||||||
HomeView(self.driver_2)
|
HomeView(self.driver_2)
|
||||||
set_password_as_new_user(device_2, device_1)
|
set_password_as_new_user(device_2, device_1)
|
||||||
|
|
||||||
device_1.back_button.click()
|
device_1.back_button.click()
|
||||||
chats_d1 = device_1.get_chats()
|
chats_d1 = device_1.get_chats()
|
||||||
chats_d1.profile_button.click()
|
chats_d1.profile_button.click()
|
||||||
|
@ -25,34 +26,55 @@ class TestGroupChats(MultiplyDeviceTestCase):
|
||||||
chats_d2.public_key_edit_box.send_keys(key)
|
chats_d2.public_key_edit_box.send_keys(key)
|
||||||
chats_d2.confirm()
|
chats_d2.confirm()
|
||||||
chats_d2.confirm_public_key_button.click()
|
chats_d2.confirm_public_key_button.click()
|
||||||
|
user_name_d1 = chats_d2.user_name_text.text
|
||||||
user_d1_name = chats_d2.user_name_text.text
|
|
||||||
|
|
||||||
device_2.back_button.click()
|
device_2.back_button.click()
|
||||||
chats_d2.new_group_chat_button.click()
|
chats_d2.new_group_chat_button.click()
|
||||||
|
|
||||||
profile_d1.back_button.click()
|
user_contact = chats_d2.element_by_text(user_name_d1, 'button')
|
||||||
user_contact = ElementByName(self.driver_2, user_d1_name)
|
|
||||||
user_contact.scroll_to_element()
|
user_contact.scroll_to_element()
|
||||||
user_contact.click()
|
user_contact.click()
|
||||||
chats_d2.next_button.click()
|
chats_d2.next_button.click()
|
||||||
|
|
||||||
chat_name = 'new_chat'
|
chat_name = 'new_chat'
|
||||||
message_1 = 'SOMETHING'
|
message_1 = 'first SOMETHING'
|
||||||
message_2 = 'another SOMETHING'
|
message_2 = 'second SOMETHING'
|
||||||
|
message_3 = 'third SOMETHING'
|
||||||
|
|
||||||
chats_d2.name_edit_box.send_keys(chat_name)
|
chats_d2.name_edit_box.send_keys(chat_name)
|
||||||
chats_d2.save_button.click()
|
chats_d2.save_button.click()
|
||||||
|
|
||||||
|
# send_and_receive_messages
|
||||||
|
|
||||||
chats_d2.chat_message_input.send_keys(message_1)
|
chats_d2.chat_message_input.send_keys(message_1)
|
||||||
chats_d2.send_message_button.click()
|
chats_d2.send_message_button.click()
|
||||||
|
|
||||||
profile_d1.find_text(message_1)
|
profile_d1.back_button.click()
|
||||||
|
chats_d1 = profile_d1.get_chats()
|
||||||
|
chats_d1.find_full_text(message_1)
|
||||||
|
group_chat_d1 = chats_d1.element_by_text(chat_name, 'button')
|
||||||
|
group_chat_d1.click()
|
||||||
|
|
||||||
group_chat_d2 = ElementByName(self.driver_2, chat_name)
|
|
||||||
group_chat_d2.click()
|
|
||||||
chats_d2.chat_message_input.send_keys(message_2)
|
chats_d2.chat_message_input.send_keys(message_2)
|
||||||
chats_d2.send_message_button.click()
|
chats_d2.send_message_button.click()
|
||||||
|
|
||||||
group_chat_d1 = ElementByName(self.driver_1, chat_name)
|
chats_d1.find_full_text(message_2)
|
||||||
group_chat_d1.click()
|
|
||||||
profile_d1.find_text(message_2)
|
# remove_user
|
||||||
|
|
||||||
|
chats_d2.group_chat_options.click()
|
||||||
|
chats_d2.chat_settings.click()
|
||||||
|
chats_d2.confirm()
|
||||||
|
chats_d2.user_options.click()
|
||||||
|
chats_d2.remove_button.click()
|
||||||
|
device_2.back_button.click()
|
||||||
|
|
||||||
|
# chats_d2.find_full_text("You\'ve removed " + user_name_d1)
|
||||||
|
|
||||||
|
chats_d2.chat_message_input.send_keys(message_1)
|
||||||
|
chats_d2.send_message_button.click()
|
||||||
|
|
||||||
|
chats_d1.find_text_part("removed you from group chat")
|
||||||
|
message_text = chats_d1.element_by_text(message_3, 'text')
|
||||||
|
if message_text.is_element_present(20):
|
||||||
|
pytest.fail('Message is shown for the user which has been removed from the GroupChat', False)
|
||||||
|
|
|
@ -25,4 +25,4 @@ class TestSanity(SingleDeviceTestCase):
|
||||||
if 'short' not in verification:
|
if 'short' not in verification:
|
||||||
home.type_message_edit_box.send_keys(verifications["valid"]["input"])
|
home.type_message_edit_box.send_keys(verifications["valid"]["input"])
|
||||||
home.confirm()
|
home.confirm()
|
||||||
home.find_text(verifications[verification]["outcome"])
|
home.find_full_text(verifications[verification]["outcome"])
|
||||||
|
|
|
@ -15,7 +15,7 @@ class BaseElement(object):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def xpath_selector(locator, value):
|
def xpath_selector(locator, value):
|
||||||
return locator(By.XPATH, value)
|
return locator(MobileBy.XPATH, value)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def accessibility_id(locator, value):
|
def accessibility_id(locator, value):
|
||||||
|
@ -51,12 +51,18 @@ class BaseElement(object):
|
||||||
action = TouchAction(self.driver)
|
action = TouchAction(self.driver)
|
||||||
action.press(x=0, y=1000).move_to(x=200, y=-1000).release().perform()
|
action.press(x=0, y=1000).move_to(x=200, y=-1000).release().perform()
|
||||||
|
|
||||||
|
def is_element_present(self, sec=5):
|
||||||
|
try:
|
||||||
|
self.wait_for_element(sec)
|
||||||
|
return True
|
||||||
|
except TimeoutException:
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
class BaseEditBox(BaseElement):
|
class BaseEditBox(BaseElement):
|
||||||
|
|
||||||
def __init__(self, driver):
|
def __init__(self, driver):
|
||||||
super(BaseEditBox, self).__init__(driver)
|
super(BaseEditBox, self).__init__(driver)
|
||||||
self.driver = driver
|
|
||||||
|
|
||||||
def send_keys(self, value):
|
def send_keys(self, value):
|
||||||
self.find_element().send_keys(value)
|
self.find_element().send_keys(value)
|
||||||
|
@ -66,7 +72,6 @@ class BaseText(BaseElement):
|
||||||
|
|
||||||
def __init__(self, driver):
|
def __init__(self, driver):
|
||||||
super(BaseText, self).__init__(driver)
|
super(BaseText, self).__init__(driver)
|
||||||
self.driver = driver
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def text(self):
|
def text(self):
|
||||||
|
@ -77,7 +82,6 @@ class BaseButton(BaseElement):
|
||||||
|
|
||||||
def __init__(self, driver):
|
def __init__(self, driver):
|
||||||
super(BaseButton, self).__init__(driver)
|
super(BaseButton, self).__init__(driver)
|
||||||
self.driver = driver
|
|
||||||
|
|
||||||
def click(self):
|
def click(self):
|
||||||
self.find_element().click()
|
self.find_element().click()
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from views.base_element import BaseElement, BaseButton
|
from views.base_element import BaseElement, BaseButton, BaseEditBox, BaseText
|
||||||
|
|
||||||
|
|
||||||
class BackButton(BaseButton):
|
class BackButton(BaseButton):
|
||||||
|
@ -8,12 +8,6 @@ class BackButton(BaseButton):
|
||||||
self.locator = self.Locator.xpath_selector("//*[@content-desc='toolbar-back-button']")
|
self.locator = self.Locator.xpath_selector("//*[@content-desc='toolbar-back-button']")
|
||||||
|
|
||||||
|
|
||||||
class ElementByName(BaseButton):
|
|
||||||
def __init__(self, driver, user_name):
|
|
||||||
super(ElementByName, self).__init__(driver)
|
|
||||||
self.locator = self.Locator.xpath_selector('//*[@text="' + user_name + '"]')
|
|
||||||
|
|
||||||
|
|
||||||
class BaseViewObject(object):
|
class BaseViewObject(object):
|
||||||
|
|
||||||
def __init__(self, driver):
|
def __init__(self, driver):
|
||||||
|
@ -23,10 +17,28 @@ class BaseViewObject(object):
|
||||||
def confirm(self):
|
def confirm(self):
|
||||||
self.driver.keyevent(66)
|
self.driver.keyevent(66)
|
||||||
|
|
||||||
def find_text(self, text):
|
def find_full_text(self, text):
|
||||||
element = BaseElement(self.driver)
|
element = BaseElement(self.driver)
|
||||||
element.locator = element.Locator.xpath_selector('//*[@text="' + text + '"]')
|
element.locator = element.Locator.xpath_selector('//*[@text="' + text + '"]')
|
||||||
return element.wait_for_element(120)
|
return element.wait_for_element(60)
|
||||||
|
|
||||||
|
def find_text_part(self, text):
|
||||||
|
element = BaseElement(self.driver)
|
||||||
|
element.locator = element.Locator.xpath_selector('//*[contains(@text, "' + text + '")]')
|
||||||
|
return element.wait_for_element(60)
|
||||||
|
|
||||||
|
def element_by_text(self, text, element_type='base'):
|
||||||
|
|
||||||
|
element_types = {
|
||||||
|
'base': BaseElement,
|
||||||
|
'button': BaseButton,
|
||||||
|
'edit_box': BaseEditBox,
|
||||||
|
'text': BaseText
|
||||||
|
}
|
||||||
|
|
||||||
|
element = element_types[element_type](self.driver)
|
||||||
|
element.locator = element.Locator.xpath_selector('//*[@text="' + text + '"]')
|
||||||
|
return element
|
||||||
|
|
||||||
def get_chats(self):
|
def get_chats(self):
|
||||||
from views.chats import ChatsViewObject
|
from views.chats import ChatsViewObject
|
||||||
|
|
|
@ -61,6 +61,28 @@ class NewGroupChatButton(BaseButton):
|
||||||
self.locator = self.Locator.xpath_selector(
|
self.locator = self.Locator.xpath_selector(
|
||||||
"//android.widget.TextView[@text='SAVE']")
|
"//android.widget.TextView[@text='SAVE']")
|
||||||
|
|
||||||
|
class GroupChatOptions(BaseButton):
|
||||||
|
def __init__(self, driver):
|
||||||
|
super(NewGroupChatButton.GroupChatOptions, self).__init__(driver)
|
||||||
|
self.locator = self.Locator.xpath_selector(
|
||||||
|
"//android.view.ViewGroup[2]//android.widget.TextView[@text='n']")
|
||||||
|
|
||||||
|
class ChatSettings(BaseButton):
|
||||||
|
def __init__(self, driver):
|
||||||
|
super(NewGroupChatButton.ChatSettings, self).__init__(driver)
|
||||||
|
self.locator = self.Locator.xpath_selector("//android.widget.TextView[@text='Settings']")
|
||||||
|
|
||||||
|
class UserOptions(BaseButton):
|
||||||
|
def __init__(self, driver):
|
||||||
|
super(NewGroupChatButton.UserOptions, self).__init__(driver)
|
||||||
|
self.locator = self.Locator.xpath_selector('//android.widget.ImageView[@content-desc="chat-icon"]'
|
||||||
|
'/../..//android.view.View')
|
||||||
|
|
||||||
|
class RemoveButton(BaseButton):
|
||||||
|
def __init__(self, driver):
|
||||||
|
super(NewGroupChatButton.RemoveButton, self).__init__(driver)
|
||||||
|
self.locator = self.Locator.xpath_selector("//android.widget.TextView[@text='Remove']")
|
||||||
|
|
||||||
|
|
||||||
class PublicKeyEditBox(BaseEditBox):
|
class PublicKeyEditBox(BaseEditBox):
|
||||||
|
|
||||||
|
@ -118,6 +140,10 @@ class ChatsViewObject(BaseViewObject):
|
||||||
self.next_button = NewGroupChatButton.NextButton(self.driver)
|
self.next_button = NewGroupChatButton.NextButton(self.driver)
|
||||||
self.name_edit_box = NewGroupChatButton.NameEditBox(self.driver)
|
self.name_edit_box = NewGroupChatButton.NameEditBox(self.driver)
|
||||||
self.save_button = NewGroupChatButton.SaveButton(self.driver)
|
self.save_button = NewGroupChatButton.SaveButton(self.driver)
|
||||||
|
self.group_chat_options = NewGroupChatButton.GroupChatOptions(self.driver)
|
||||||
|
self.chat_settings = NewGroupChatButton.ChatSettings(self.driver)
|
||||||
|
self.user_options = NewGroupChatButton.UserOptions(self.driver)
|
||||||
|
self.remove_button = NewGroupChatButton.RemoveButton(self.driver)
|
||||||
|
|
||||||
self.chat_message_input = ChatMessageInput(self.driver)
|
self.chat_message_input = ChatMessageInput(self.driver)
|
||||||
self.send_message_button = SendMessageButton(self.driver)
|
self.send_message_button = SendMessageButton(self.driver)
|
||||||
|
|
Loading…
Reference in New Issue