Ejemplo n.º 1
0
    def setUp(self):
        device = '9f85839'
        # 删除手机中的MP4文件
        os.system('adb -s %s shell rm /sdcard/case03.mp4' % (device))
        print device + '手机MP4已删除'
        # 删除电脑的MP4文件
        vivo_mp4 = 'E:/vivo_MP4/case03.mp4'
        if os.path.exists(vivo_mp4):
            os.remove(vivo_mp4)
            print '电脑vivo_MP4已删除'
        else:
            print '电脑没有vivo_MP4文件'

        # 初始化uiautomator2
        d2 = uiautomator2.connect_usb(device)
        print 'uiautomator初始化完成'

        # 启动微信
        # os.system('adb -s %s shell am force-stop com.tencent.mm' % (device))
        # os.system('adb -s %s shell am start com.tencent.mm/.ui.LauncherUI' % (device))
        # print '微信已重启'

        # 初始化H5Drvier
        # d2(resourceId="com.tencent.mm:id/b6e", text=u"文件传输助手").click()
        d2(resourceId="com.tencent.mm:id/apn").click()
        sleep(3)
        self.h5Driver = H5Driver(device)
        self.h5Driver.initDriver()

        # 启动手机录屏
        self.vivo_child = subprocess.Popen(
            'adb -s %s shell screenrecord --bit-rate 4000000 /sdcard/case03.mp4'
            % (device))
        print device + '录屏启动成功'
Ejemplo n.º 2
0
    def vivo_H5(self, device, d2):

        # 微信X5内核调试打开
        d2(resourceId="com.tencent.mm:id/b6e", text=u"文件传输助手").click()

        # 重置微信调试
        # d2(resourceId="com.tencent.mm:id/oe", className="android.view.View", instance=1).click()
        # sleep(4)
        # d2.click(681, 1602)
        # d2(resourceId="com.tencent.mm:id/oe", className="android.view.View", instance=2).click()
        # d2(text=u"安装线上内核").click()
        # sleep(30)
        # d2(resourceId="android:id/button1").click()

        # 进入H5链接
        d2(resourceId="com.tencent.mm:id/oe",
           className="android.view.View",
           instance=3).click()
        sleep(3)

        # 初始化mi8_H5Drvier
        self.vivo_h5Driver = H5Driver(device)
        self.vivo_h5Driver.initDriver()
        print 'vivo初始化H5Driver完成'
        self.vivo_h5Driver.wait(3)
        return self.vivo_h5Driver
Ejemplo n.º 3
0
    def mi9_H5(self, device, d2):

        # 打开微信X5调试
        d2(resourceId="com.tencent.mm:id/b6e", text=u"文件传输助手").click()

        # 重置微信调试
        # d2(resourceId="com.tencent.mm:id/oe", className="android.view.View", instance=5).click()
        # sleep(4)
        # d2.click(482, 1394)
        # d2(resourceId="com.tencent.mm:id/oe", className="android.view.View", instance=6).click()
        # d2(text=u"安装线上内核").click()
        # sleep(35)
        # d2(resourceId="android:id/button1").click()

        # 进入H5链接
        d2(resourceId="com.tencent.mm:id/oe",
           className="android.view.View",
           instance=7).click()
        sleep(3)

        # 初始化mi9_H5Driver
        self.mi9_h5Driver = H5Driver(device)
        self.mi9_h5Driver.initDriver()
        print 'mi9初始化H5Driver完成'
        self.mi9_h5Driver.wait(2)
Ejemplo n.º 4
0
def h5Driver_init(d2):
    d2(resourceId="com.tencent.mm:id/b6e", text=u"文件传输助手").click()
    # 进入H5链接
    d2(resourceId="com.tencent.mm:id/oe",
       className="android.view.View",
       instance=3).click()
    sleep(3)
    h5Driver = H5Driver()
    h5Driver.initDriver()
    h5Driver.wait(3)
    return h5Driver
Ejemplo n.º 5
0
def testScript():
    # R9S  device = 'bdefdc13'
    # x9007  device = '93f42dca'
    print "start test..."

    h5Driver = H5Driver()
    h5Driver.wait(1)
    h5Driver.d(text="发现").click()
    h5Driver.wait(1)
    h5Driver.d(text="购物").click()
    h5Driver.wait(15)

    h5Driver.initDriver()
    url = "http://h5.baike.qq.com/mobile/enter.html"
    h5Driver.navigateToPage(url)
    h5Driver.wait(15)

    h5Driver.wait(1)
    pa = h5Driver.getElementByXpath('/html/body/div[1]/div/div[3]/p')
    print 'getElementByXpath', pa
    h5Driver.wait(1)
    pa = h5Driver.getElementTextByXpath('//p[@class="disease-all"]')
    print 'getElementTextByXpath', pa
    h5Driver.wait(1)
    # 全部疾病
    h5Driver.clickElementByXpath('//p[@class="disease-all"]')
    h5Driver.wait(1)
    h5Driver.clickFirstElementByText('白内障')
    print "进入白内障"
    h5Driver.returnLastPage()
    h5Driver.returnLastPage()

    txt = h5Driver.getElementByXpath('//p[@class="disease-all"]')
    print 'getElementByXpath', txt
    txt = h5Driver.getElementTextByXpath('//p[@class="disease-all"]')
    print 'getElementTextByXpath', txt
    currhtml = h5Driver.getCurrentPageUrl()
    print "当前url:", currhtml
    context = h5Driver.getAllContext()
    print 'context', context
    node = h5Driver.getBodyNode()
    print 'node', node
    memory = h5Driver.getMemoryInfo()
    print 'memory', memory
    # cpu = h5Driver.getCPUInfo()
    # print 'cpu', cpu
    document = h5Driver.getDocument()
    print 'document', document
    # 关闭整个H5窗口
    h5Driver.wait(3)
    h5Driver.closeWindow()
Ejemplo n.º 6
0
    def test_app(self):
        time.sleep(3)
        self.driver.find_element(By.XPATH, serach_btn).click()
        logger.info('点击搜索')
        self.driver.find_element_by_id(serach_id).send_keys(app_name)
        logger.info('搜索得到')
        self.driver.find_element_by_id(app_icon).click()
        logger.info('点击小程序')

        time.sleep(5)

        h5Driver = H5Driver()
        h5Driver.initDriver()
        h5Driver.clickElementByXpath('/html/body/div/div[2]/div[2]/div[1]/a')
        h5Driver.clickFirstElementByText('白内障')
        h5Driver.returnLastPage()
        h5Driver.returnLastPage()
        print(h5Driver.getElementTextByXpath('/html/body/div[1]/div/div[3]/p'))
        h5Driver.close()
Ejemplo n.º 7
0
# coding=utf-8
'''
Tencent is pleased to support the open source community by making FAutoTest available.
Copyright (C) 2018 THL A29 Limited, a Tencent company. All rights reserved.
Licensed under the BSD 3-Clause License (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
https://opensource.org/licenses/BSD-3-Clause
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 fastAutoTest.core.h5.h5Engine import H5Driver

# http://h5.baike.qq.com/mobile/enter.html 从微信进入此链接,首屏加载完后执行脚本
if __name__ == '__main__':
    h5Driver = H5Driver()
    h5Driver.initDriver()
    h5Driver.clickElementByXpath('/html/body/div[1]/div/div[3]/p')
    h5Driver.clickFirstElementByText('白内障')
    h5Driver.returnLastPage()
    h5Driver.returnLastPage()
    print(h5Driver.getElementTextByXpath('/html/body/div[1]/div/div[3]/p'))
    h5Driver.close()