Beispiel #1
0
    def _select_case(self, role, case):
        """Select the test case.
        """
        # select the case
        elem = Select(self._browser.find_element_by_id('select-dut'))
        elem.select_by_value(str(role))
        time.sleep(1)

        checkbox = None
        wait_until(lambda: self._browser.find_elements_by_css_selector('.tree-node .tree-title') and True)
        elems = self._browser.find_elements_by_css_selector('.tree-node .tree-title')
        finder = re.compile(r'.*\b' + case + r'\b')
        finder_dotted = re.compile(r'.*\b' + case.replace(' ', r'\.') + r'\b')
        for elem in elems:
            action_chains = ActionChains(self._browser)
            action_chains.move_to_element(elem)
            action_chains.perform()
            logger.debug(elem.text)
            if finder.match(elem.text) or finder_dotted.match(elem.text):
                parent = elem.find_element_by_xpath('..')
                checkbox = parent.find_element_by_class_name('tree-checkbox')
                break

        if not checkbox:
            time.sleep(5)
            raise Exception('Failed to find the case')

        self._browser.execute_script("$('.overview').css('left', '0')")
        checkbox.click()
        time.sleep(1)

        elem = self._browser.find_element_by_id('runTest')
        elem.click()
        if not wait_until(lambda: self._browser.find_element_by_id('stopTest') and True, 10):
            raise Exception('Failed to start test case')
Beispiel #2
0
    def _select_case(self, role, case):
        """Select the test case.
        """
        # select the case
        elem = Select(self._browser.find_element_by_id('select-dut'))
        elem.select_by_value(str(role))
        time.sleep(1)

        checkbox = None
        wait_until(lambda: self._browser.find_elements_by_css_selector('.tree-node .tree-title') and True)
        elems = self._browser.find_elements_by_css_selector('.tree-node .tree-title')
        finder = re.compile(r'.*\b' + case + r'\b')
        finder_dotted = re.compile(r'.*\b' + case.replace(' ', r'\.') + r'\b')
        for elem in elems:
            action_chains = ActionChains(self._browser)
            action_chains.move_to_element(elem)
            action_chains.perform()
            logger.debug(elem.text)
            if finder.match(elem.text) or finder_dotted.match(elem.text):
                parent = elem.find_element_by_xpath('..')
                checkbox = parent.find_element_by_class_name('tree-checkbox')
                break

        if not checkbox:
            time.sleep(5)
            raise Exception('Failed to find the case')

        self._browser.execute_script("$('.overview').css('left', '0')")
        checkbox.click()
        time.sleep(1)

        elem = self._browser.find_element_by_id('runTest')
        elem.click()
        if not wait_until(lambda: self._browser.find_element_by_id('stopTest') and True, 10):
            raise Exception('Failed to start test case')
    def _select_case(self, suite, case):
        """Select the test case.
        """
        # select the case
        elem = Select(self._browser.find_element_by_id('select-dut'))
        elem.select_by_value(str(suite))
        time.sleep(1)

        checkbox = None
        elems = self._browser.find_elements_by_css_selector('.tree-node .tree-title')
        for elem in elems:
            action_chains = ActionChains(self._browser)
            action_chains.move_to_element(elem)
            action_chains.perform()
            logger.debug(elem.text)
            if elem.text.startswith(case):
                parent = elem.find_element_by_xpath('..')
                checkbox = parent.find_element_by_class_name('tree-checkbox')
                break

        if not checkbox:
            time.sleep(5)
            raise Exception('Failed to find the case')

        checkbox.click()
        time.sleep(1)

        elem = self._browser.find_element_by_id('runTest')
        elem.click()
        if not self.wait_until(lambda: self._browser.find_element_by_id('stopTest') and True, 10):
            raise Exception('Failed to start test case')
    def _select_case(self, role, case):
        """Select the test case.
        """
        # select the case
        elem = Select(self._browser.find_element_by_id('select-dut'))
        elem.select_by_value(str(role))
        time.sleep(1)

        checkbox = None
        wait_until(lambda: self._browser.find_elements_by_css_selector(
            '.tree-node .tree-title') and True)
        elems = self._browser.find_elements_by_css_selector(
            '.tree-node .tree-title')
        finder = re.compile(r'.*\b' + case + r'\b')
        finder_dotted = re.compile(r'.*\b' + case.replace(' ', r'\.') + r'\b')
        for elem in elems:
            # elem.txt might be null when the required reference devices could
            # not be met (either due to the quantity or the type) for specific test.
            # perform() will throw exceptions if elem.text is null since Chrome
            # and chromedriver 80. If elem is not shown in current case list
            # window, move_to_element() will not work either.
            if not elem.text:
                continue
            # execute a javascript to scroll the window to the elem
            self._browser.execute_script('arguments[0].scrollIntoView();',
                                         elem)
            action_chains = ActionChains(self._browser)
            action_chains.move_to_element(elem)
            action_chains.perform()
            logger.debug(elem.text)
            if finder.match(elem.text) or finder_dotted.match(elem.text):
                parent = elem.find_element_by_xpath('..')
                checkbox = parent.find_element_by_class_name('tree-checkbox')
                break

        if not checkbox:
            time.sleep(5)
            raise Exception('Failed to find the case')

        self._browser.execute_script("$('.overview').css('left', '0')")
        checkbox.click()
        time.sleep(1)

        elem = self._browser.find_element_by_id('runTest')
        elem.click()
        if not wait_until(
                lambda: self._browser.find_element_by_id('stopTest') and True,
                10):
            raise Exception('Failed to start test case')
Beispiel #5
0
    def _select_case(self, suite, case):
        """Select the test case.
        """
        # select the case
        elem = Select(self._browser.find_element_by_id('select-dut'))
        elem.select_by_value(str(suite))
        time.sleep(1)

        checkbox = None
        self.wait_until(lambda: self._browser.find_elements_by_css_selector('.tree-node .tree-title') and True)
        elems = self._browser.find_elements_by_css_selector('.tree-node .tree-title')
        for elem in elems:
            action_chains = ActionChains(self._browser)
            action_chains.move_to_element(elem)
            action_chains.perform()
            logger.debug(elem.text)
            if elem.text.startswith(case):
                parent = elem.find_element_by_xpath('..')
                checkbox = parent.find_element_by_class_name('tree-checkbox')
                break
driver.find_element_by_id('quick_transfer').click()
a = Select(driver.find_element_by_id('transfer_from'))
a.select_by_visible_text('กระเป๋าเงินหลัก')
driver.implicitly_wait(10)
b = Select(driver.find_element_by_id('transfer_to'))
b.select_by_visible_text('Sexy Gaming กระเป๋าเงิน')
c = driver.find_element_by_id('transfer_amount')
c.send_keys('1')
driver.find_element_by_id('transfer_button').click()
time.sleep(2)
if len(driver.find_elements_by_xpath("//*[text()='รายการสำเร็จ']")) == 0:
    print('Failed Transfer in Sexy Gaming!')
    driver.save_screenshot(
        "C:\PyCharm Community Edition 2019.1.3\SCS188\Screenshots\Failed_Transfer_SexyGaming.png"
    )
else:
    print('Successful transfer in Sexy Gaming!')
time.sleep(2)
d = driver.find_element_by_class_name('modal-header.panel-heading')
d.find_element_by_class_name('close').click()
time.sleep(1)

driver.find_element_by_id('transferAllToMainBtn').click()
driver.implicitly_wait(60)
a = driver.find_element_by_class_name('modal-content')
a.find_element_by_xpath("//button[@class='close.pull-right']").click()
time.sleep(2)
driver.find_element_by_class_name('refreshBalanceButton.btn').click()
time.sleep(2)

driver.quit()