示例#1
0
 def _go_to_more_settings(self):
     """
     进入更多设置
     """
     self.log_and_pub('Go to more settings...')
     self._go_to_homepage()
     bottom_settings_iv = find_ele_by_cnl(self.driver,
                                          'android.widget.ImageView',
                                          location=self.bottom_settings_loc)
     bottom_settings_iv.click()
     more_settings_iv = find_ele_by_cnl(self.driver,
                                        'android.widget.ImageView',
                                        location=self.more_settings_loc)
     more_settings_iv.click()
示例#2
0
 def _go_to_homepage(self):
     """
     回到主页
     """
     self.log_and_pub('Go to home page...')
     if self._is_home_page():
         return
     homepage_btn = find_ele_by_cnl(self.driver,
                                    'android.widget.ImageView',
                                    location=self.bottom_homepage_loc)
     homepage_btn.click()
     if self._is_home_page():
         return
     homepage_btn = find_ele_by_cnl(self.driver,
                                    'android.widget.ImageView',
                                    location=self.bottom_homepage_loc)
     homepage_btn.click()
示例#3
0
 def _refresh_page(self):
     """
     刷新页面
     """
     self.log_and_pub('Refresh page...')
     bottom_settings_iv = find_ele_by_cnl(self.driver,
                                          'android.widget.ImageView',
                                          location=self.bottom_settings_loc)
     bottom_settings_iv.click()
     self.driver.find_element_by_name('刷新').click()
示例#4
0
 def _active_url(self):
     """
     激活进入输入网址页面
     """
     self.log_and_pub('Active url input element...')
     self.driver.wait_activity('com.uc.browser.InnerUCMobile', 10, 2)
     active_url = find_ele_by_cnl(self.driver,
                                  'android.view.View',
                                  location=self.active_url_loc)
     active_url.click()
示例#5
0
 def _page_down(self):
     """
     向下翻页
     """
     self.log_and_pub('Page down...')
     lib_driver.scroll_down(self.driver, self.device_window_size)
     try:
         # 判断是否有长点击导致的弹出框
         if find_ele_by_cnl(self.driver, 'android.widget.TextView',
                            self.pop_loc):
             self.driver.keyevent(4)
     except:
         pass
     lib_driver.scroll_down(self.driver, self.device_window_size)
     try:
         # 判断是否有长点击导致的弹出框
         if find_ele_by_cnl(self.driver, 'android.widget.TextView',
                            self.pop_loc):
             self.driver.keyevent(4)
     except:
         pass
示例#6
0
 def _is_home_page(self):
     """
     检查是否是主页,通过查找页面中是否有 网址、小说、视频、奇趣、生活的viewgroup
     """
     five_small_dragon_loc = lib_tools.get_loc_from_str(
         self.conf[self.device]['UC']['five_small_dragon_location'])
     five_small_dragon = find_ele_by_cnl(self.driver,
                                         'android.view.ViewGroup',
                                         location=five_small_dragon_loc)
     if five_small_dragon:
         return True
     return False
示例#7
0
 def get_version(self):
     """
     获取浏览器版本
     """
     self.log_and_pub('Get version...')
     self._go_to_bottom_in_settings()
     version_tv = find_ele_by_cnl(self.driver,
                                  'android.widget.TextView',
                                  location=self.version_loc)  # 版本号
     version = version_tv.text
     self.log_and_pub('The current version is %s.' % version)
     self.version_conf[self.device]['XIAOMI_NATIVE']['version'] = version
     self.version_conf.write()
     self._send_key_back()
示例#8
0
 def _open_link(self, link):
     """
     打开一个链接
     """
     self.driver.wait_activity('com.uc.browser.InnerUCMobile', 10, 2)
     self._go_to_homepage()
     self.driver.wait_activity('com.uc.browser.InnerUCMobile', 10, 2)
     self._active_url()
     url = find_ele_by_cnl(self.driver,
                           'android.view.View',
                           location=self.url_loc)
     url.click()  # 使输入url获取焦点
     lib_driver.input_content(self.conf[self.device]['deviceName'], link)
     time.sleep(self.loadpage_time)
示例#9
0
 def change_adblock(self, open=True):
     """
     更改广告拦截
     """
     self.log_and_pub('Change adblock...')
     self._go_to_more_settings()
     adblock = find_ele_by_cnl(self.driver,
                               'android.widget.ImageView',
                               location=self.adblock_loc)  # 广告过滤
     if adblock.is_selected() is not open:
         adblock.click()
         self.log_and_pub(
             '修改UC浏览器广告过滤状态,打开广告过滤!' if open else '修改UC浏览器广告过滤状态,关闭广告过滤!')
     else:
         self.log_and_pub('无需修改UC浏览器广告过滤状态,当前为打开广告过滤。'
                          if open else '无需修改UC浏览器广告过滤状态,当前为关闭广告过滤。')
     self._send_key_back()
示例#10
0
 def get_version(self):
     """
     获取浏览器版本
     """
     self.log_and_pub('Get version...')
     self._go_to_more_settings()
     lib_driver.scroll(self.driver,
                       self.driver.find_element_by_name('WiFi助手'),
                       self.driver.find_element_by_name('下载设置'))
     version_tv = find_ele_by_cnl(self.driver,
                                  'android.widget.TextView',
                                  location=self.version_loc)  # 版本号
     self.log_and_pub('The current version is %s.' %
                      version_tv.text.split(' ')[1])
     version = version_tv.text.split(' ')[1]
     self.version_conf[self.device]['UC']['version'] = version
     self.version_conf.write()
     self._send_key_back()
示例#11
0
 def change_adblock(self, open=True):
     """
     更改广告拦截
     """
     self.log_and_pub('Change adblock...')
     self._go_to_bottom_in_settings()
     self.driver.find_element_by_name('高级').click()
     adblock = find_ele_by_cnl(self.driver,
                               'android.widget.CheckBox',
                               location=self.adblock_loc)  # 广告过滤
     if adblock.get_attribute('checked') != 'true':
         adblock.click()
         self.log_and_pub('修改XIAOMI native浏览器广告过滤状态,打开广告过滤!'
                          if open else '修改XIAOMI native浏览器广告过滤状态,关闭广告过滤!')
     else:
         self.log_and_pub('无需修改XIAOMI native浏览器广告过滤状态,当前为打开广告过滤。' if open
                          else '无需修改XIAOMI native浏览器广告过滤状态,当前为关闭广告过滤。')
     self._send_key_back()
     self._send_key_back()
     self._send_key_back()
示例#12
0
 def change_cloud_accelerator(self, open=True):
     """
     更改云端加速
     """
     self.log_and_pub('Change clound accelerator...')
     self._go_to_more_settings()
     self.driver.find_element_by_name('极速/省流').click()
     cloud_accelerator = find_ele_by_cnl(
         self.driver,
         'android.widget.ImageView',
         location=self.cloud_accelerator_loc)  # 云端加速
     if cloud_accelerator.is_selected() is not open:
         cloud_accelerator.click()
         self.log_and_pub(
             '修改UC浏览器云端加速状态,打开云端加速!' if open else '修改UC浏览器云端加速状态,关闭云端加速!')
     else:
         self.log_and_pub('无需修改UC浏览器云端加速状态,当前为打开云端加速。'
                          if open else '无需修改UC浏览器云端加速状态,当前为关闭云端加速。')
     self._send_key_back()
     self._send_key_back()