How to use the toolium.pageobjects.page_object.PageObject function in toolium

To help you get started, we’ve selected a few toolium examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Telefonica / toolium-examples / android / pageobjects / drag_and_drop.py View on Github external
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""

from selenium.webdriver.common.by import By
from appium.webdriver.common.touch_action import TouchAction

from toolium.pageobjects.page_object import PageObject
from toolium.pageelements import *


class DragAndDropPageObject(PageObject):
    dot1 = PageElement(By.ID, 'io.appium.android.apis:id/drag_dot_1')
    dot2 = PageElement(By.ID, 'io.appium.android.apis:id/drag_dot_2')
    dot3 = PageElement(By.ID, 'io.appium.android.apis:id/drag_dot_3')
    result = Text(By.ID, 'io.appium.android.apis:id/drag_result_text')

    def drag_and_drop(self):
        TouchAction(self.driver).long_press(self.dot3.web_element).move_to(self.dot2.web_element).release().perform()
github Telefonica / toolium / toolium / pageobjects / page_object.py View on Github external
def wait_until_loaded(self, timeout=None):
        """Wait until page object is loaded
        Search all page elements configured with wait=True

        :param timeout: max time to wait
        :returns: this page object instance
        """
        for element in self._get_page_elements():
            if hasattr(element, 'wait') and element.wait:
                from toolium.pageelements.page_element import PageElement
                if isinstance(element, PageElement):
                    # Pageelement and Group
                    element.wait_until_visible(timeout)
                if isinstance(element, PageObject):
                    # PageObject and Group
                    element.wait_until_loaded(timeout)
        return self
github Telefonica / toolium-examples / ios / pageobjects / calc.py View on Github external
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""

from selenium.webdriver.common.by import By
from appium.webdriver.common.mobileby import MobileBy

from toolium.pageobjects.page_object import PageObject
from toolium.pageelements import *


class CalcPageObject(PageObject):
    first_op = InputText(By.XPATH, '//XCUIElementTypeTextField[1]')
    second_op = InputText(By.XPATH, '//XCUIElementTypeTextField[2]')
    compute = Button(MobileBy.ACCESSIBILITY_ID, 'ComputeSumButton')
    result = Text(By.XPATH, '//XCUIElementTypeStaticText[1]')
    status_bar = PageElement(By.XPATH, '//XCUIElementTypeStatusBar[1]')

    def sum(self, first_number, second_number):
        """Add two numbers

        :param first_number: first value
        :param second_number: second value
        :returns: calc page object
        """
        self.first_op.wait_until_visible()
        self.first_op.text = first_number
        self.second_op.text = second_number
github Telefonica / toolium-examples / web_lettuce / pageobjects / login.py View on Github external
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""

from selenium.webdriver.common.by import By

from toolium.pageobjects.page_object import PageObject
from toolium.pageelements import *
from web_lettuce.pageobjects.message import MessagePageObject
from web_lettuce.pageobjects.secure_area import SecureAreaPageObject


class LoginPageObject(PageObject):
    username = InputText(By.ID, 'username')
    password = InputText(By.ID, 'password')
    login_button = Button(By.XPATH, "//form[@id='login']/button")
    message = MessagePageObject()

    def open(self):
        """ Open login url in browser

        :returns: this page object instance
        """
        self.driver.get('{}/login'.format(self.config.get('Test', 'url')))
        return self

    def wait_until_loaded(self):
        """ Wait until login page is loaded
github Telefonica / toolium-examples / web_behave / pageobjects / login.py View on Github external
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""

from selenium.webdriver.common.by import By

from toolium.pageobjects.page_object import PageObject
from toolium.pageelements import *
from web_behave.pageobjects.message import MessagePageObject
from web_behave.pageobjects.secure_area import SecureAreaPageObject


class LoginPageObject(PageObject):
    def init_page_elements(self):
        self.username = InputText(By.ID, 'username')
        self.password = InputText(By.ID, 'password')
        self.login_button = Button(By.XPATH, "//form[@id='login']/button")
        self.message = MessagePageObject()

    def open(self):
        """ Open login url in browser

        :returns: this page object instance
        """
        self.driver.get('{}/login'.format(self.config.get('Test', 'url')))
        return self

    def wait_until_loaded(self):
        """ Wait until login page is loaded
github Telefonica / toolium-examples / web / pageobjects / secure_area.py View on Github external
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""

from selenium.webdriver.common.by import By

from toolium.pageobjects.page_object import PageObject
from toolium.pageelements import *
from web.pageobjects.message import MessagePageObject


class SecureAreaPageObject(PageObject):
    message = MessagePageObject()
    logout_button = Button(By.XPATH, "//div[@id='content']//a[contains(@class,'button')]")

    def logout(self):
        """ Log out of secure area

        :returns: login page object instance
        """
        from web.pageobjects.login import LoginPageObject

        self.logout_button.click()
        return LoginPageObject(self.driver_wrapper).wait_until_loaded()
github Telefonica / toolium-examples / android / pageobjects / menu.py View on Github external
http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""

from appium.webdriver.common.mobileby import MobileBy

from toolium.pageobjects.page_object import PageObject


class MenuPageObject(PageObject):
    option_locator = 'new UiScrollable(new UiSelector().scrollable(true).instance(0))' \
                     '.scrollIntoView(new UiSelector().text("{}").instance(0));'

    def open_option(self, option):
        """Search a menu option and click on it

        :param option: str with menu option
        :returns: this page object instance
        """
        self.driver.find_element(MobileBy.ANDROID_UIAUTOMATOR, self.option_locator.format(option)).click()
        return self
github Telefonica / toolium-examples / web / pageobjects / login.py View on Github external
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""

from selenium.webdriver.common.by import By

from toolium.pageobjects.page_object import PageObject
from toolium.pageelements import *
from web.pageobjects.message import MessagePageObject
from web.pageobjects.secure_area import SecureAreaPageObject


class LoginPageObject(PageObject):
    username = InputText(By.ID, 'username')
    password = InputText(By.ID, 'password')
    login_button = Button(By.XPATH, "//form[@id='login']/button")
    message = MessagePageObject()

    def open(self):
        """ Open login url in browser

        :returns: this page object instance
        """
        self.driver.get('{}/login'.format(self.config.get('Test', 'url')))
        return self

    def wait_until_loaded(self):
        """ Wait until login page is loaded
github Telefonica / toolium-examples / android / pageobjects / tabs.py View on Github external
http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""

from selenium.webdriver.common.by import By

from toolium.pageobjects.page_object import PageObject
from toolium.pageelements import *


class TabsPageObject(PageObject):
    tab_xpath = '(//android.widget.TabWidget//android.widget.TextView)[{}]'
    tab1 = Button(By.XPATH, tab_xpath.format('1'))
    tab2 = Button(By.XPATH, tab_xpath.format('2'))
    tab3 = Button(By.XPATH, tab_xpath.format('3'))
    content1 = Text(By.ID, 'io.appium.android.apis:id/view1')
    content2 = Text(By.ID, 'io.appium.android.apis:id/view2')
    content3 = Text(By.ID, 'io.appium.android.apis:id/view3')
    container = PageElement(By.ID, 'android:id/content')