Appium [求助] 启动 appium,模拟器以后,运行脚本无任何反应

flying · 2014年03月19日 · 最后由 flying 回复于 2014年03月20日 · 2141 次阅读

首先申明我不是懒人啊,appium 里面所有的帖子,所有的回复全部看完了,还是无法解决
现在有几个问题全部是在 windows 下面:
1.单独下载安装 node,但是我解压 appium 发现也有一个 node,这一步是多余的么?
2.在 node 下面
分别

npm install appium
npm install wd
没有设置 android 的环境变量,但是手动起了模拟器,安装好测试程序,打开界面,这个时候在 Eclipse 上写了一段脚本,然后运行让他去操作程序,但是发现在 appium 上没有任何 log 打印出来,程序也没动,是不是一定需要 unittest 这种东西,才可以啊
3.如果只有一个 apk 包,是不是不能使用 appium 了,必须知道它的 app-packge 和 app-activity

贴上代码:


# -*- coding:utf-8 -*-
'''
Created on Feb 9, 2014

@author: fo43
'''

import os
import glob
import unittest
import selenium
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

class sql(object):
    def __init__(self,desired_caps):
        self.desired_caps=desired_caps
        self.driver=webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)

    def test(self):
        self.driver.find_element_by_class_xpath("//Button[0]").click()
        print "no"

PATH= lambda p:os.path.abspath(os.path.join(os.path.dirname(__file__),p))


testone=sql(

            {
            'device': 'Selendroid',
            #'app': 'D:\svn\oe\bin\oe.apk',
            #'browserName': '',
            #'version': '4.2.2',
            'app-package': 'game.oe',
            'app-activity': 'game.oe.button'
            }  
            )
a=sql.driver.find_elements_by_name("level") 
a.click()


共收到 3 条回复 时间 点赞

安装 appium 有 2 个方式

  1. 直接通过 node 安装 或者
  2. 用 windows 下已经封装好的 appium 可执行程序

如果你自己跑用例, 你可以贴下你的代码, 看看他连接的是不是启动的 appium 端口 4723, 需要检查下。

新版本的 appium 已经不依赖那两个参数了, 指定了 apk 就会自己自动分析的,当然还是推荐你自己写上那两个参数。比较保险。

  1. 这一步是多余的,appium for windows 下已经有编译好的文件了 2. windows 下直接双击 appium.exe 就可以了 3. apk 包自己用 apktool 解包一下,可以看到那俩参数 建议看一下新手帖 http://testerhome.com/topics/496

#1 楼 @seveniruby 我用的是 0.16 版本,他会自动分析么?
我已经贴上了代码,但是一运行会报错,

Finding files... done.
Importing test modules ... Traceback (most recent call last):
  File "D:\eclipse\plugins\org.python.pydev.debug_2.4.0.2012020116\pysrc\pydev_runfiles.py", line 307, in __get_module_from_str
    mod = __import__(modname)
  File "D:/svn/pyton/android\sql.py", line 37, in <module>
    'app-activity': 'game.oe.button'
  File "D:/svn/pyton/android\sql.py", line 20, in __init__
    self.driver=webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
  File "D:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 71, in __init__
    self.start_session(desired_capabilities, browser_profile)
  File "D:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 113, in start_session
    'desiredCapabilities': desired_capabilities,
  File "D:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 164, in execute
    self.error_handler.check_response(response)
  File "D:\Python27\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 136, in check_response
    raise exception_class(value)
WebDriverException: Message: u'\ufeff<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\r\n<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">\r\n<head>\r\n \r\n<title>Error Message</title>\r\n<meta http-equiv="content-type" content="text/html; charset=utf-8" />\r\n\r\n<style>\r\nbody {\r\n\t\r\n\tbackground:#e5eaf5 url(/Wbo-8F0ADB97-5282-4CBD-A019-24C869E0000C/bg.gif) top left repeat-x ;\r\n\tmargin:0px 0px 0px 0px;\r\n\tfont-family:Arial, Helvetica, sans-serif;\r\n\tmin-width:1000px;\r\n\tfont-size:12px;\r\n\tcolor:#000000;\r\n\tdirection:ltr;\r\n\t}\r\nimg {border:none}\r\n\r\n\r\n\t.main {\r\n\t\twidth:100%;\r\n\t\tbackground:url(/Wbo-8F0ADB97-5282-4CBD-A019-24C869E0000C/topright.gif) top right no-repeat;\r\n\t\tmin-width:1000px;\r\n\t\tmin-height:400px;\r\n\t\tmargin-left:auto;\r\n\t\tmargin-right:auto;\r\n\t\ttext-align:left;\r\n\t}\r\n\t\r\n\t.logo {float:left;  height:103px; }\r\n\t.sidetext {float:right; width:182px; height:52px; background:url(/Wbo-8F0ADB97-5282-4CBD-A019-24C869E0000C/sidetext.png) top left; border:1px solid #2a2e31; margin-right:20px; margin-top:20px; padding:4px; }\r\n\t.sidetextNone {visibility:hidden; }\r\n\t\r\n\t.whiteline {float:left; clear:both; font-size:20px; margin-left:47px; margin-top:17px; color:#ffffff; white-space:nowrap; }\r\n\t.bold {font-weight:bold;}\r\n\t\r\n\t.maintext {float:left; margin-top:20px; clear:both; color:#000; margin-left:47px;}\r\n\t\r\n\t.color1 {color:#677183;}\r\n\t\r\n\tul {margin-top:0; padding-left:15px; padding-top:5px; padding-bottom:5px;}\r\n\t\r\n\tul li {list-style-image:url(/Wbo-8F0ADB97-5282-4CBD-A019-24C869E0000C/bullet.gif)}\r\n\tA {\r\n    FONT-WEIGHT: bold; COLOR: #005a80;\r\n}\r\nA:hover {\r\n    FONT-WEIGHT: bold;COLOR: #0d3372;\r\n}\r\n</style>\r\n  \r\n</head>\r\n<body>\r\n\t<div class="main">\r\n        <div class="logo"><img src="/Wbo-8F0ADB97-5282-4CBD-A019-24C869E0000C/logo.png" alt="ForeFront" /></div>\r\n        <div class="whiteline"><td id=L_10061_2><span class="bold">Network Access Message:</span> The page cannot be displayed </td></div>\r\n    <div class="maintext">\r\n    <td id=L_10061_3><span class="bold color1">Explanation:</span> The Web server refused the connection.  </td><br />\r\n<br />\r\n\r\n<td id=L_10061_5><span class="bold color1">Try the following:</span></td><br />\r\n\r\n<ul>\r\n<li><td id=L_10061_6><span class="bold">Refresh page:</span> Search for the page again by clicking the Refresh button. The timeout could have occurred due to Internet congestion.   </td></li>\r\n<li><td id=L_10061_7><span class="bold">Check spelling:</span> Check that the Web page address is spelled correctly. The address may have been mistyped.</td></li>\r\n<li><td id=L_10061_8><span class="bold">Access from a link:</span> If there is a link to the page you are looking for, try accessing the page from that link. </td></li>\r\n<li><td id=L_10061_9><span class="bold">Contact website:</span>You may want to contact the website administrator to make sure the Web page still exists. You can do this by using the e-mail address or phone number listed on the website home page.</td></li>\r\n</ul>\r\n<br />\r\n\r\n<td id=L_10061_10><span>If you are still not able to view the requested page, try contacting your administrator or Helpdesk.</span></td> <br />\r\n\r\n<br />\r\n<td id=L_10061_11><span class="bold color1">Technical Information (for support personnel)</span></td><br />\r\n<ul>\r\n<li><td id=L_10061_12><span class="bold">Error Code 10061:</span> Connection refused</td></li>\r\n<li><td id=L_10061_13><span class="bold">Background:</span>The server you are attempting to access has refused the connection with the gateway. This usually results from trying to connect to a service that is inactive on the server.</td></li>\r\n<li><td id=L_10061_14><span class="bold">Date:</span></td> 3/19/2014 5:26:12 AM [GMT]</li>\r\n<li><td id=L_10061_15><span class="bold">Server:</span></td> st01tmg03.buyabs.corp </li>\r\n<li><td id=L_10061_16><span class="bold">Source:</span> Remote server </td></li>\r\n</ul>\r\n    </div>\r\n</div>\r\n</body>\r\n</html>' 
ERROR: Module: sql could not be imported (file: D:\svn\pyton\android\sql.py).
done.

----------------------------------------------------------------------
Ran 0 tests in 0.000s

4楼 已删除
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册