Esempio n. 1
0
    def main(self) -> Main:
        # todo: wait main page
        def wait_load(driver):
            print(datetime.datetime.now())
            source = self._driver.page_source
            if "我的" in source:
                return True
            if "同意" in source:
                return True
            if "image_cancel" in source:
                return True
            return False

        WebDriverWait(self._driver, 30).until(wait_load)
        return Main(self._driver)
Esempio n. 2
0
    def main(self):
        def wait_load(driver):
            print(datetime.datetime.now())
            source = self._driver.page_source
            if "我的" in source:
                return True
            if "同意" in source:
                return True
            if "image_cancel" in source:
                return True
            return False

        WebDriverWait(self._driver, 20).until(wait_load)
        # lambda表达式写法
        # WebDriverWait(self._driver, 20).until(lambda x: "同意" in self._driver.page_source)
        return Main(self._driver)
Esempio n. 3
0
    def main(self):
        def is_loaded(driver):
            loaded_tag = ['同意', '我的']
            source = self._driver.page_source
            for tag in loaded_tag:
                if tag in source:
                    return True

                if loaded_tag[-1] == tag:
                    return False

            return True

        logging.info('wait main page init.')
        # wait main page init
        WebDriverWait(self._driver, 30).until(is_loaded)
        return Main(self._driver)
Esempio n. 4
0
    def main(self) -> Main:
        # todo:广告点击 done
        # print("chent:"+self._driver.page_source)
        # 当页面加载出[我的]或者[同意],后续代码才走
        def wait_load(driver):
            print(datetime.datetime.now())
            source = self._driver.page_source
            if "我的" in source:
                return True
            if "同意" in source:
                return True
            if "image_cancel" in source:
                return True
            return False

        # WebDriverWait(self._driver, 10).until(lambda x: 'com.xueqiu.android:id/logo' in self._driver.page_source)
        WebDriverWait(self._driver, 10).until(wait_load)
        return Main(self._driver)
Esempio n. 5
0
    def wait_load_main(self):
        def wait_load(driver):
            print(datetime.datetime.now())
            # 以下任意一个元素出现在page_source中则表示首页加载完成
            source = self._driver.page_source
            # if "我的" in source:
            #     return True
            # if "同意" in source:
            #     return True
            # if "image_cancel" in source:
            #     return True
            # return False
            _source_list = ["我的", "同意", "image_cancel"]
            for ele in _source_list:
                if ele in source:
                    return True
            return False

        # 显示等待首页加载完成
        WebDriverWait(self._driver, 10).until(wait_load)
        return Main(self._driver)
Esempio n. 6
0
 def main(self):
     return Main(self._driver)
Esempio n. 7
0
 def main(self) -> Main:
     # todo: wait mian page
     return Main(self._driver)
Esempio n. 8
0
 def main(self) -> Main:
     #传递driver
     return Main(self._driver)
Esempio n. 9
0
 def logout(self):
     from test_appium.page.main import Main
     return Main(self._driver)
Esempio n. 10
0
 def main(self) -> Main:
     return Main(self._driver)