• #8 楼 @weamylady python 的 UiAutomator 模块是吧? 安装时不会弹窗么? 我去研究下。

  • #6 楼 @xuxu 全干掉了,moto 的机器拿回来什么都没装就这样子。昨天试了另外一 moto 的机器也是这样子。

  • #2 楼 @snake 小米的机器依然令我头疼

  • #3 楼 @xuxu 要装的,没执行一次所用的包都是不同的,我们一个版本会出很多 debug 包,每次都要用最新的包做测试。 而且我目前是每执行一个 task 前安装一下,一个 task 可能包含很多 case。

  • 支持一下

  • #28 楼 @weamylady 嗯,page_source 都获取不到,自然也就没法定位。我是用 uiautomator 获取元素坐标,再用 adb shell input tap 点击的,这样可以绕过。还是希望 selendroid 能解决这个 bug 吧。

    def __uidump(self):
        #获取当前Activity控件树
        self.tempFile = tempfile.gettempdir()
        self.pattern = re.compile(r"\d+") 
        xml = "/data/local/tmp/uidump.xml"
        os.popen("adb -s {0} shell uiautomator dump {1}".format(self.device_id, xml))
        os.popen("adb -s {0} pull {1} {2}".format(self.device_id, xml, self.tempFile))
    
    def get_element_point(self, attrib, name, nub):
        """
        根据元素查找坐标,返回的坐标为元素中心点
        传入元素类型、名称、下标,其中有多个元素时通过下标控制,默认为0
    
        :Usage:
            self.__element("resource-id","scorebar",0)
        """      
        self.__uidump()
        x = []
        y = []
        tree = ET.ElementTree(file=os.path.join(self.tempFile, "uidump.xml"))
        treeIter = tree.iter(tag="node")
        for elem in treeIter:
            if elem.attrib[attrib] == name:
                bounds = elem.attrib["bounds"]
                coord = self.pattern.findall(bounds)
                Xpoint = (int(coord[2]) + int(coord[0])) / 2.0
                Ypoint = (int(coord[3]) + int(coord[1])) / 2.0
                x.append(Xpoint)
                y.append(Ypoint)
        return x[nub], y[nub]          
    
  • desired_caps['deviceName'] = '192.168.56.101:5555'
    

    这是啥玩意儿,不应该配置模拟器吗

  • #26 楼 @weamylady 暂时无解,只能用 uiautomation view 来查看元素

  • #15 楼 @chenhengjie123 是 IOS 的,谢谢了。

  • #21 楼 @weamylady 是的,我也遇到了,有些页面我打印 page_source 直接报错了

  • #13 楼 @chenhengjie123

    我测试的 app 中有一个选择城市的页面,这个页面可以向下滚动,每次执行到这个页面时,appium 就会先把所有的页面元素获取出来,包括向下滚动才能看到的元素。
    由于元素非常多,需要 1 分钟才能获取完成,这个速度简直不能忍,有没有什么办法可以让 appium 只获取当前屏幕的元素吗?我记得 android 是只能获取当前屏幕的。

  • #19 楼 @weamylady 目前我所知道的在 selendroid 模式下,除了要用 Value 来定位,ByID 的格式也不一样,要去掉 com.xxx.xxx:id/ ,而且 swip 方法在 4.2 及以下设备上失效(可以通过 adb shell input touchscreen swipe 绕过),scoll 方法失效。就连页面上的 textview 和 imageview 有时都会变成 Novatextview 和 Novaimageview,到处都是坑。

  • #11 楼 @chenhengjie123 很奇怪,selendroid 模式下所有的 ListView 和 TextView 都变成了 NovaListView 和 NovaTextView,我把 Xpath 修改一下就可以了。

  • Swipe 问题报错求解? at 2015年05月06日

    driver 的 swip 方法在 selendroid 模式下只对 4.4 以上设备有效

  • Swipe 问题报错求解? at 2015年05月06日
    def swipe(self,startx,starty,endx,endy,duration):
        '''
        startx和starty为起点坐标,endx和endy为终点坐标,duration为滑动时间,单位ms
        agent:
        self.swipe(1079,1919,1079,1,4000)
        '''
        os.popen("adb shell input touchscreen swipe "+ str(startx) + " " + str(starty) + " " + str(endx) + " " + str(endy) + " " + str(duration))
    
    
  • #11 楼 @chenhengjie123 谢谢你的指正,by_link_text 可以找到。Xpath 我是直接复制 Appium Inspector 的。我先研究下 selendroid 的文档,多谢。

  • #7 楼 @chenhengjie123 如上,我打印出来是有这个元素的,by name 却找不到,xpath 也不行。

  • #7 楼 @chenhengjie123

    def test_ActionButton(self): #首页8个按钮,3屏
        for i in range(100):
            activity = self.driver.current_activity
            if activity == "com.dianping.main.city.CityListSwitchActivity" :
                time.sleep(2)
                break
            else:
                time.sleep(2)
        print self.driver.page_source
        el = self.driver.find_element_by_name("北京") 
        el.click() 
    
  • #7 楼 @chenhengjie123

    info: [debug] Proxied response received with status 200: {"value":"<?xml version=\"1.0\" encoding=\"UTF-8\"?><views><DecorView name=\"\" label=\"\" value=\"\" ref=\"a632f262-1a0f-86ae-6786-828e3425c61e\" id=\"\" shown=\"true\"><rect x=\"0\" y=\"0\" height=\"1280\" width=\"720\"/><FrameLayout name=\"\" label=\"\" value=\"\" ref=\"7315298b-fb33-a68d-f165-3f3c765b84f1\" id=\"windowBorder\" shown=\"true\"><rect x=\"0\" y=\"0\" height=\"1280\" width=\"720\"/><LinearLayout name=\"\" label=\"\" value=\"\" ref=\"57613bac-f8e0-815c-c0a9-346c2f412b91\" id=\"windowContentFrame\" shown=\"true\"><rect x=\"0\" y=\"0\" height=\"1280\" width=\"720\"/><ImageView name=\"\" label=\"\" value=\"\" ref=\"a036e6b6-869e-48dd-4792-8203e87faa0c\" id=\"windowIconic\" shown=\"false\"><rect x=\"0\" y=\"0\" height=\"0\" width=\"0\"/></ImageView><LinearLayout name=\"\" label=\"\" value=\"\" ref=\"98b1472f-c4b7-2dd0-e3e0-4c37aacef932\" id=\"\" shown=\"true\"><rect x=\"0\" y=\"0\" height=\"1280\" width=\"720\"/><LinearLayout name=\"\" label=\"\" value=\"\" ref=\"dd1fc08d-f9ed-ad49-f83b-d1bd33741666\" id=\"\" shown=\"true\"><rect x=\"0\" y=\"0\" height=\"1280\" width=\"720\"/><ViewStub name=\"\" label=\"\" value=\"\" ref=\"c2f52aae-f129-bd3b-6b79-40be3ff9eda3\" id=\"action_mode_bar_stub\" shown=\"false\"><rect x=\"0\" y=\"0\" height=\"0\" width=\"0\"/></ViewStub><FrameLayout name=\"\" label=\"\" value=\"\" ref=\"05ebe8d3-5e33-24b2-59a5-83920dc13fbf\" id=\"title_container\" shown=\"true\"><rect x=\"0\" y=\"50\" height=\"100\" width=\"720\"/><FrameLayout name=\"\" label=\"\" value=\"\" ref=\"efb8f90b-ca89-198a-781a-b2d983669ff7\" id=\"title_bar\" shown=\"true\"><rect x=\"0\" y=\"50\" height=\"100\" width=\"720\"/><FrameLayout name=\"\" label=\"\" value=\"\" ref=\"ec3c9c62-af1e-0084-3d6a-74754797dd9f\" id=\"title_bar_content_container\" shown=\"true\"><rect x=\"0\" y=\"60\" height=\"80\" width=\"690\"/><ShopListTabView name=\"\" label=\"\" value=\"\" ref=\"b36ede0e-4893-6359-d352-0eb435b22976\" id=\"\" shown=\"true\"><rect x=\"0\" y=\"60\" height=\"80\" width=\"690\"/><NovaLinearLayout name=\"\" label=\"\" value=\"\" ref=\"9e55bab1-cb0b-2a34-ce6a-b001377de200\" id=\"tab1\" shown=\"true\"><rect x=\"185\" y=\"70\" height=\"60\" width=\"160\"/><TextView name=\"\" label=\"\" value=\"全部\" ref=\"e08abc4c-18dd-5149-54e6-947274ead764\" id=\"title1\" shown=\"true\"><rect x=\"237\" y=\"81\" height=\"38\" width=\"56\"/></TextView></NovaLinearLayout><NovaLinearLayout name=\"\" label=\"\" value=\"\" ref=\"c8b119e3-e400-8b1f-a866-98b29856b322\" id=\"tab3\" shown=\"false\"><rect x=\"0\" y=\"60\" height=\"0\" width=\"0\"/><TextView name=\"\" label=\"\" value=\"\" ref=\"0e395fad-2f58-dc9a-9965-903bad2228a8\" id=\"title3\" shown=\"false\"><rect x=\"0\" y=\"60\" height=\"0\" width=\"0\"/></TextView></NovaLinearLayout><NovaLinearLayout name=\"\" label=\"\" value=\"\" ref=\"0b78e0a1-7804-4f95-f1cc-f32fcec24bdb\" id=\"tab2\" shown=\"true\"><rect x=\"345\" y=\"70\" height=\"60\" width=\"160\"/><TextView name=\"\" label=\"\" value=\"海外\" ref=\"4e813b8c-166f-d42c-5dc3-6d24354c037d\" id=\"title2\" shown=\"true\"><rect x=\"397\" y=\"81\" height=\"38\" width=\"56\"/></TextView></NovaLinearLayout></ShopListTabView></FrameLayout><LinearLayout name=\"\" label=\"\" value=\"\" ref=\"3968182f-98e7-9b07-58dc-0e713717bc07\" id=\"title_bar_left_view_container\" shown=\"true\"><rect x=\"0\" y=\"60\" height=\"80\" width=\"80\"/><CustomImageButton name=\"\" label=\"\" value=\"\" ref=\"006b6274-5957-5adc-49fd-c0598dd64e7b\" id=\"left_view\" shown=\"true\"><rect x=\"0\" y=\"60\" height=\"80\" width=\"80\"/></CustomImageButton></LinearLayout><LinearLayout name=\"\" label=\"\" value=\"\" ref=\"ea96617b-77b8-95b5-b1fe-c04f32332179\" id=\"title_bar_right_view_container\" shown=\"true\"><rect x=\"690\" y=\"60\" height=\"80\" width=\"0\"/></LinearLayout></FrameLayout></FrameLayout><FrameLayout name=\"\" label=\"\" value=\"\" ref=\"e2dbeb9f-21ab-2347-d4ed-e5222a3b4010\" id=\"content\" shown=\"true\"><rect x=\"0\" y=\"150\" height=\"1130\" width=\"720\"/><LinearLayout name=\"\" label=\"\"
     value=\"\" ref=\"289328d0-4609-17c3-6ab2-c501d6626ef9\" id=\"\" shown=\"true\"><rect x=\"0\" y=\"150\" height=\"1130\" width=\"720\"/><LinearLayout name=\"\" label=\"\" value=\"\" ref=\"2051abac-200b-70b4-73e8-eddd3b42d894\" id=\"\" shown=\"true\"><rect x=\"0\" y=\"150\" height=\"101\" width=\"720\"/><ButtonSearchBar name=\"\" label=\"\" value=\"\" ref=\"6415e433-228d-814d-72f7-0929ff3b75c1\" id=\"button_search_bar\" shown=\"true\"><rect x=\"0\" y=\"150\" height=\"100\" width=\"720\"/><NovaLinearLayout name=\"\" label=\"\" value=\"\" ref=\"4ef6e1e9-e9e4-93c7-9976-ed6bce1bb71f\" id=\"search_layout\" shown=\"true\"><rect x=\"50\" y=\"179\" height=\"43\" width=\"622\"/><ImageView name=\"\" label=\"\" value=\"\" ref=\"9683c922-887a-e646-9ef6-e0a963d823e5\" id=\"search_icon\" shown=\"true\"><rect x=\"50\" y=\"185\" height=\"30\" width=\"52\"/></ImageView><TextView name=\"\" label=\"\" value=\"\" ref=\"6a008ef3-b983-4a17-b4e5-8e0450899079\" id=\"start_search\" shown=\"true\"><rect x=\"102\" y=\"179\" height=\"43\" width=\"570\"/></TextView></NovaLinearLayout></ButtonSearchBar><View name=\"\" label=\"\" value=\"\" ref=\"15eadf93-f95a-7dac-101b-4b8b01b81eb4\" id=\"\" shown=\"true\"><rect x=\"0\" y=\"250\" height=\"1\" width=\"720\"/></View></LinearLayout><RelativeLayout name=\"\" label=\"\" value=\"\" ref=\"f7ce828b-369d-5d17-acb9-b750d809e420\" id=\"\" shown=\"true\"><rect x=\"0\" y=\"251\" height=\"1029\" width=\"720\"/><NovaListView name=\"\" label=\"\" value=\"\" ref=\"3af43816-7cac-678e-3fab-e27a3d2cef9f\" id=\"list\" shown=\"true\"><rect x=\"0\" y=\"251\" height=\"1029\" width=\"720\"/><NovaTextView name=\"\" label=\"\" value=\"上海  GPS定位\" ref=\"3777db6d-6141-4e88-04fb-a416015e2d47\" id=\"text1\" shown=\"true\"><rect x=\"0\" y=\"251\" height=\"100\" width=\"720\"/></NovaTextView><CityGridLayout name=\"\" label=\"\" value=\"\" ref=\"1e557533-3d3d-135b-d712-4dfb0147f750\" id=\"\" shown=\"true\"><rect x=\"0\" y=\"350\" height=\"0\" width=\"720\"/><LinearLayout name=\"\" label=\"\" value=\"\" ref=\"5e2dc57d-40e6-a7cc-d41a-2316c1f7f9da\" id=\"\" shown=\"true\"><rect x=\"0\" y=\"350\" height=\"0\" width=\"720\"/><LinearLayout name=\"\" label=\"\" value=\"\" ref=\"5ab168d4-257b-8ec6-9969-e4b186293781\" id=\"layout\" shown=\"false\"><rect x=\"0\" y=\"350\" height=\"0\" width=\"0\"/><TextView name=\"\" label=\"\" value=\"常用\" ref=\"9e640494-f69b-823e-1aad-c8ddb15f6f2a\" id=\"city_title\" shown=\"false\"><rect x=\"0\" y=\"350\" height=\"0\" width=\"0\"/></TextView><LinearLayout name=\"\" label=\"\" value=\"\" ref=\"836bf452-585e-e90e-7d09-5f65c7b3fb55\" id=\"recommend_category_container\" shown=\"false\"><rect x=\"0\" y=\"350\" height=\"0\" width=\"0\"/></LinearLayout></LinearLayout></LinearLayout></CityGridLayout><CityGridLayout name=\"\" label=\"\" value=\"\" ref=\"517994ad-8106-f810-6155-c5392ed277ff\" id=\"\" shown=\"true\"><rect x=\"0\" y=\"349\" height=\"472\" width=\"720\"/><LinearLayout name=\"\" label=\"\" value=\"\" ref=\"4adeca2a-fc3c-0c04-3581-191be5ec6614\" id=\"\" shown=\"true\"><rect x=\"0\" y=\"349\" height=\"472\" width=\"720\"/><LinearLayout name=\"\" label=\"\" value=\"\" ref=\"2f2adc4b-f9e8-e6d3-04c5-0e4b9ed20cb3\" id=\"layout\" shown=\"true\"><rect x=\"0\" y=\"349\" height=\"472\" width=\"720\"/><TextView name=\"\" label=\"\" value=\"热门国内城市\" ref=\"72219a70-66f2-4e4a-f2f1-51206c995ecf\" id=\"city_title\" shown=\"true\"><rect x=\"0\" y=\"349\" height=\"92\" width=\"720\"/></TextView><LinearLayout name=\"\" label=\"\" value=\"\" ref=\"6f611b63-af9d-c145-4b58-b4128e398203\" id=\"recommend_category_container\" shown=\"true\"><rect x=\"0\" y=\"441\" height=\"380\" width=\"720\"/><LinearLayout name=\"\" label=\"\" value=\"\" ref=\"b5185893-d3fb-b5c0-e11d-93f33a60b0ec\" id=\"\" shown=\"true\"><rect x=\"20\" y=\"441\" height=\"95\" width=\"680\"/><NovaTextView name=\"\" label=\"\" value=\"上海\" ref=\"955548ea-700b-da28-b2c6-d4b0be78f1dd\" id=\"\" shown=\"true\"><rect x=\"28\" y=\"449\" height=\"79\" width=\"210\"/></NovaTextView><NovaTextView name=\"\" label=\"\" value=\"北京\" ref=\"93ae96
    48-ced9-1f25-e7d1-a9aa6c3f6d63\" id=\"\" shown=\"true\"><rect x=\"254\" y=\"449\" height=\"79\" width=\"211\"/></NovaTextView><NovaTextView name=\"\" label=\"\" value=\"广州\" ref=\"d386e692-d282-b396-e4d9-7ec52cef6fed\" id=\"\" shown=\"true\"><rect x=\"481\" y=\"449\" height=\"79\" width=\"211\"/></NovaTextView></LinearLayout><LinearLayout name=\"\" label=\"\" value=\"\" ref=\"ccec1c0f-4db7-c78b-b904-d2a7e4095e02\" id=\"\" shown=\"true\"><rect x=\"20\" y=\"536\" height=\"95\" width=\"680\"/><NovaTextView name=\"\" label=\"\" value=\"深圳\" ref=\"9ae81fa4-44fd-b96c-1f87-0159b2657526\" id=\"\" shown=\"true\"><rect x=\"28\" y=\"544\" height=\"79\" width=\"210\"/></NovaTextView><NovaTextView name=\"\" label=\"\" value=\"成都\" ref=\"7ca2aa20-645b-aa36-ebf8-41d42446f85c\" id=\"\" shown=\"true\"><rect x=\"254\" y=\"544\" height=\"79\" width=\"211\"/></NovaTextView><NovaTextView name=\"\" label=\"\" value=\"重庆\" ref=\"7607df9c-df90-be2b-c023-95b6db60e671\" id=\"\" shown=\"true\"><rect x=\"481\" y=\"544\" height=\"79\" width=\"211\"/></NovaTextView></LinearLayout><LinearLayout name=\"\" label=\"\" value=\"\" ref=\"aeb87f2d-d35e-7d8f-a305-05b18d17aae7\" id=\"\" shown=\"true\"><rect x=\"20\" y=\"631\" height=\"95\" width=\"680\"/><NovaTextView name=\"\" label=\"\" value=\"天津\" ref=\"f9a4686e-e5bc-6334-bc39-861f60098628\" id=\"\" shown=\"true\"><rect x=\"28\" y=\"639\" height=\"79\" width=\"210\"/></NovaTextView><NovaTextView name=\"\" label=\"\" value=\"杭州\" ref=\"e0820233-c1b8-2807-8e50-30045ff35031\" id=\"\" shown=\"true\"><rect x=\"254\" y=\"639\" height=\"79\" width=\"211\"/></NovaTextView><NovaTextView name=\"\" label=\"\" value=\"南京\" ref=\"205a527d-c561-bc79-8b58-052020a352bb\" id=\"\" shown=\"true\"><rect x=\"481\" y=\"639\" height=\"79\" width=\"211\"/></NovaTextView></LinearLayout><LinearLayout name=\"\" label=\"\" value=\"\" ref=\"19bf87fb-4096-d06d-5f83-5901d7bd40d0\" id=\"\" shown=\"t
    info: <-- GET /wd/hub/session/759cae02-f87e-d839-00a2-823886eaf632/source 200 468.826 ms - 14837 
    info: --> POST /wd/hub/session/759cae02-f87e-d839-00a2-823886eaf632/element {"using":"name","sessionId":"759cae02-f87e-d839-00a2-823886eaf632","value":"北京"}
    info: [debug] Proxying command to localhost:8080
    info: [debug] Making http request with opts: {"url":"http://localhost:8080/wd/hub/session/759cae02-f87e-d839-00a2-823886eaf632/element","method":"POST","json":{"using":"name","sessionId":"759cae02-f87e-d839-00a2-823886eaf632","value":"北京"}}
    
    info: [debug] Responding to client with error: {"status":7,"value":{"message":"An element could not be located on the page using the given search parameters.","origValue":"Element was not found."},"sessionId":"759cae02-f87e-d839-00a2-823886eaf632"}
    
    info: <-- POST /wd/hub/session/759cae02-f87e-d839-00a2-823886eaf632/element 500 5099.663 ms - 201 
    
    info: --> GET /wd/hub/status {}
    
    info: [debug] Proxying command to localhost:8080
    info: [debug] Making http request with opts: {"url":"http://localhost:8080/wd/hub/status","method":"GET"}
    
    info: [debug] Proxied response received with status 200: {"value":{"supportedApps":[],"build":{"browserName":"selendroid","version":"0.13.0"},"os":{"arch":"armeabi-v7a","version":"17","name":"Android"},"supportedDevices":[]},"status":0}
    
    
  • 楼主,我用 1.3.7,使用 selendroid 模式在 4.2 的机器上运行,查找元素时 by xpath 和 by name 都失效了,有遇到过吗

  • appium.app Inspector 启动方法 at 2015年04月24日

    #13 楼 @wqy8576 你的应用是不是有签名校验,appium 安装是会重签名的

  • 鄙视这种解决了不说怎么解决的,我来造福一下后人吧,点开 appium 上得 android 或者 ios 图标,设置好 APP Path 和 device id,然后启动 appium 再点击 Inspector 就可以正常使用了

  • 什么情况?

  • 如何实现长按某个元素 at 2015年01月12日

    #2 楼 @xingjizhao 看下 action 有哪些方法,python 里是 long_press(),js 有可能格式不一样

  • 如何实现长按某个元素 at 2015年01月12日

    善用搜索

    var action = new wd.TouchAction(driver);
    action
      .tap({el: el, x: 10, y: 10})
      .release();
    return action.long_press().perform();