#16 楼 @yuwuhen333 main 就是默认全部运行了吧
#14 楼 @yuwuhen333 10 个 py?每个都打个包,然后 import 到一个 py 中
#12 楼 @yuwuhen333 你详细描述下你的需求
['NATIVE_APP', 'WEBVIEW_com.travelsky.bluesky']
Traceback (most recent call last):
File "D:\appium\ccarehybridtest.py", line 22, in <module>
dr.switch_to.context("WEBVIEW_com.travelsky.bluesky")
File "C:\Python34\lib\site-packages\appium\webdriver\switch_to.py", line 31, in context
self._driver.execute(MobileCommand.SWITCH_TO_CONTEXT, {'name': context_name})
File "C:\Python34\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 173, in execute
response = self.command_executor.execute(driver_command, params)
File "C:\Python34\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 349, in execute
return self._request(command_info[0], url, body=data)
File "C:\Python34\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 417, in _request
resp = opener.open(request)
File "C:\Python34\lib\urllib\request.py", line 463, in open
response = self._open(req, data)
File "C:\Python34\lib\urllib\request.py", line 481, in _open
'_open', req)
File "C:\Python34\lib\urllib\request.py", line 441, in _call_chain
result = func(*args)
File "C:\Python34\lib\urllib\request.py", line 1210, in http_open
return self.do_open(http.client.HTTPConnection, req)
File "C:\Python34\lib\urllib\request.py", line 1185, in do_open
r = h.getresponse()
File "C:\Python34\lib\http\client.py", line 1171, in getresponse
response.begin()
File "C:\Python34\lib\http\client.py", line 351, in begin
version, status, reason = self._read_status()
File "C:\Python34\lib\http\client.py", line 313, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "C:\Python34\lib\socket.py", line 374, in readinto
return self._sock.recv_into(b)
[Decode error - output not utf-8]
为什么叫处女座用例
选个稳定点的 nodejs,0.10.25 不错~
#17 楼 @yuwuhen333 不了解,webview 的定位,你可以先了解下 webdriver
#14 楼 @yuwuhen333 webview 是 HTML 格式,xpath,css,name,id 都可以定位
#13 楼 @yuwuhen333 什么意思?uiautomatorview 还是 uiautomator,说清楚
#1 楼 @wang04170 你测的是 hybrid 应用么
#6 楼 @qddegtya 你好,我用了你得 demo 试了一下,没能成功
报错信息如下,然后我加了 platformName 跟 deviceName 上去,还是同样的报错~
Traceback (most recent call last):
File "D:\appium\ccarehybridtest1.py", line 20, in <module>
driver = webdriver.Remote("http://192.168.10.56:9515/wd/hub", capabilities)
File "C:\Python34\lib\site-packages\appium\webdriver\webdriver.py", line 35, in __init__
super(WebDriver, self).__init__(command_executor, desired_capabilities, browser_profile, proxy, keep_alive)
File "C:\Python34\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 74, in __init__
self.start_session(desired_capabilities, browser_profile)
File "C:\Python34\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 123, in start_session
'desiredCapabilities': desired_capabilities,
File "C:\Python34\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 175, in execute
self.error_handler.check_response(response)
File "C:\Python34\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 166, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: A new session could not be created. (Original error: The following desired capabilities are required, but were not provided: platformName, deviceName)
[Finished in 1.1s with exit code 1]
好长,辛苦了!
#18 楼 @chenhengjie123
实际上我切换的代码就三行
self.driver.implicitly_wait(10)
a=self.driver.contexts
print (a)
#18 楼 @chenhengjie123 请问 hybrid app,用 python 实现 hybrid 切换到 webview 怎么弄呢?
我这样尝试的
#coding=utf-8
import os
import unittest,sys,time,re,datetime,HTMLTestRunner
from appium import webdriver
from time import sleep
from appium.common.exceptions import NoSuchContextException
import sys
from selenium.webdriver.support.ui import WebDriverWait
#reload(sys)
#sys.setdefaultencoding("utf-8")
# Returns abs path relative to this file and not cwd
PATH = lambda p: os.path.abspath(
os.path.join(os.path.dirname(__file__), p)
)
class ContactsAndroidTests(unittest.TestCase):
def setUp(self):
desired_caps = {}
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '4.4'
desired_caps['deviceName'] = '192.168.56.101:5555'
'''desired_caps['app'] = PATH(
'../../../sample-code/apps/ContactManager/ContactManager.apk'
)'''
desired_caps['appPackage'] = 'com.jiudao.ccare'
desired_caps['appActivity'] = '.MainActivity'
desired_caps["unicodeKeyboard"] = "True"
desired_caps["resetKeyboard"] = "True"
self.driver = webdriver.Remote('http://192.168.10.177:4723/wd/hub', desired_caps)
#self.driver.implicitly_wait(1)
def login(self):
#登录操作
#time.sleep(3)
self.driver.implicitly_wait(10)
a=self.driver.contexts
print (a)
self.driver.switch_to.context("pt1.1")
if __name__ == '__main__':
suite = unittest.TestSuite()
suite.addTest(ContactsAndroidTests("login"))
timestr = time.strftime('%Y%m%d%H%M%S',time.localtime(time.time()))
filename = "D:\\appium\\appiumresult\\result_" + timestr + ".html"
print (filename)
fp = open(filename, 'wb')
runner = HTMLTestRunner.HTMLTestRunner(
stream=fp,
title='测试结果',
description='测试报告'
)
runner.run(suite)
#g_browser.quit()
fp.close() #测试报告关闭
这是我获得的测试报告,我 print 出来的东西是 pt1.1
#1 楼 @lihuazhang 好的