请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

获取不到toast,提示selenium.common.exceptions.TimeoutException: Message:

# -*- coding:utf-8 -*-
from appium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as Ec
import time
capabilites ={
    "platformName":"Android",
    "automationName":"UiAutomator2",
    "deviceName":"I76PBE4D45EADQSS",
    "app":"D:\\mukewang.apk"
    }
driver=webdriver.Remote("http://127.0.0.1:4723/wd/hub",capabilites)
time.sleep(20)

def get_toast():
    toast_element=("xpath","//*[contains(@text,'请输入密码')]")
    WebDriverWait(driver,30,0.01).until(Ec.presence_of_element_located(toast_element)
   
driver.find_element_by_android_uiautomator('new UiSelector().resourceId("cn.com.open.mooc:id/account_edit")').send_keys('11223344')
time.sleep(2)
driver.find_element_by_android_uiautomator('new UiSelector().resourceId("cn.com.open.mooc:id/login_lable")').click()
get_toast()

运行后提示

Traceback (most recent call last):
  File "D:\Program Files (x86)\eclipse\workspace\AppiumPython\case\start_appium.py", line 122, in <module>
    get_toast() 
  File "D:\Program Files (x86)\eclipse\workspace\AppiumPython\case\start_appium.py", line 98, in get_toast
    WebDriverWait(driver,30,0.01).until(Ec.presence_of_element_located(toast_element))   
  File "C:\Program Files\Python36\lib\site-packages\selenium\webdriver\support\wait.py", line 80, in until
    raise TimeoutException(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message:

Appium端提示

 info: --> POST /wd/hub/session/016083e1-5a97-4349-9d38-03faaf772e7f/element {"using":"xpath","value":"//*[contains(@text,u'璇疯緭鍏ュ瘑鐮?)]","sessionId":"016083e1-5a97-4349-9d38-03faaf772e7f"}
> info: [debug] Waiting up to 0ms for condition
> info: [debug] Pushing command to appium work queue: ["find",{"strategy":"xpath","selector":"//*[contains(@text,u'璇疯緭鍏ュ瘑鐮?)]","context":"","multiple":false}]
> info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"xpath","selector":"//*[contains(@text,u'璇疯緭鍏ュ瘑鐮?)]","context":"","multiple":false}}
> info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
> info: [debug] [BOOTSTRAP] [debug] Got command action: find
> info: [debug] [BOOTSTRAP] [debug] Finding //*[contains(@text,u'璇疯緭鍏ュ瘑鐮?)] using XPATH with the contextId:  multiple: false
> info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":32,"value":"javax.xml.transform.TransformerException: Expected ,, but found: '璇疯緭鍏ュ瘑鐮?"}
> info: [debug] Condition unmet after 24ms. Timing out.
> info: [debug] Responding to client with error: {"status":32,"value":{"message":"Argument was an invalid selector (e.g. XPath/CSS).","origValue":"javax.xml.transform.TransformerException: Expected ,, but found: '璇疯緭鍏ュ瘑鐮?"},"sessionId":"016083e1-5a97-4349-9d38-03faaf772e7f"}
> info: <-- POST /wd/hub/session/016083e1-5a97-4349-9d38-03faaf772e7f/element 500 26.454 ms - 234 
> info: --> POST /wd/hub/session/016083e1-5a97-4349-9d38-03faaf772e7f/element {"using":"xpath","value":"//*[contains(@text,u'璇疯緭鍏ュ瘑鐮?)]","sessionId":"016083e1-5a97-4349-9d38-03faaf772e7f"}
> info: [debug] Waiting up to 0ms for condition
> info: [debug] Pushing command to appium work queue: ["find",{"strategy":"xpath","selector":"//*[contains(@text,u'璇疯緭鍏ュ瘑鐮?)]","context":"","multiple":false}]
> info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"xpath","selector":"//*[contains(@text,u'璇疯緭鍏ュ瘑鐮?)]","context":"","multiple":false}}
> info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
> info: [debug] [BOOTSTRAP] [debug] Got command action: find
> info: [debug] [BOOTSTRAP] [debug] Finding //*[contains(@text,u'璇疯緭鍏ュ瘑鐮?)] using XPATH with the contextId:  multiple: false
> info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":32,"value":"javax.xml.transform.TransformerException: Expected ,, but found: '璇疯緭鍏ュ瘑鐮?"}
> info: [debug] Condition unmet after 25ms. Timing out.
> info: [debug] Responding to client with error: {"status":32,"value":{"message":"Argument was an invalid selector (e.g. XPath/CSS).","origValue":"javax.xml.transform.TransformerException: Expected ,, but found: '璇疯緭鍏ュ瘑鐮?"},"sessionId":"016083e1-5a97-4349-9d38-03faaf772e7f"}
> info: <-- POST /wd/hub/session/016083e1-5a97-4349-9d38-03faaf772e7f/element 500 28.577 ms - 234 
> info: --> POST /wd/hub/session/016083e1-5a97-4349-9d38-03faaf772e7f/element {"using":"xpath","value":"//*[contains(@text,u'璇疯緭鍏ュ瘑鐮?)]","sessionId":"016083e1-5a97-4349-9d38-03faaf772e7f"}
> info: [debug] Waiting up to 0ms for condition
> info: [debug] Pushing command to appium work queue: ["find",{"strategy":"xpath","selector":"//*[contains(@text,u'璇疯緭鍏ュ瘑鐮?)]","context":"","multiple":false}]
> info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"xpath","selector":"//*[contains(@text,u'璇疯緭鍏ュ瘑鐮?)]","context":"","multiple":false}}
> info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
> info: [debug] [BOOTSTRAP] [debug] Got command action: find
> info: [debug] [BOOTSTRAP] [debug] Finding //*[contains(@text,u'璇疯緭鍏ュ瘑鐮?)] using XPATH with the contextId:  multiple: false
> info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":32,"value":"javax.xml.transform.TransformerException: Expected ,, but found: '璇疯緭鍏ュ瘑鐮?"}
> info: [debug] Condition unmet after 13ms. Timing out.
> info: [debug] Responding to client with error: {"status":32,"value":{"message":"Argument was an invalid selector (e.g. XPath/CSS).","origValue":"javax.xml.transform.TransformerException: Expected ,, but found: '璇疯緭鍏ュ瘑鐮?"},"sessionId":"016083e1-5a97-4349-9d38-03faaf772e7f"}
> info: <-- POST /wd/hub/session/016083e1-5a97-4349-9d38-03faaf772e7f/element 500 15.537 ms - 234 
> info: --> POST /wd/hub/session/016083e1-5a97-4349-9d38-03faaf772e7f/element {"using":"xpath","value":"//*[contains(@text,u'璇疯緭鍏ュ瘑鐮?)]","sessionId":"016083e1-5a97-4349-9d38-03faaf772e7f"}
> info: [debug] Waiting up to 0ms for condition
> info: [debug] Pushing command to appium work queue: ["find",{"strategy":"xpath","selector":"//*[contains(@text,u'璇疯緭鍏ュ瘑鐮?)]","context":"","multiple":false}]
> info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"xpath","selector":"//*[contains(@text,u'璇疯緭鍏ュ瘑鐮?)]","context":"","multiple":false}}
> info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
> info: [debug] [BOOTSTRAP] [debug] Got command action: find
> info: [debug] [BOOTSTRAP] [debug] Finding //*[contains(@text,u'璇疯緭鍏ュ瘑鐮?)] using XPATH with the contextId:  multiple: false
> info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":32,"value":"javax.xml.transform.TransformerException: Expected ,, but found: '璇疯緭鍏ュ瘑鐮?"}
> info: [debug] Condition unmet after 14ms. Timing out.



10556
收起

正在回答 回答被采纳积分+3

2回答

慕姐1291937 2019-03-22 18:19:33

你好,请问下您的问题解决没呢?我也遇到了一样的问题,怎么弄都解决不了

0 回复 有任何疑惑可以回复我~
  • 你是乱码还是没找到,这是两个概念。
    回复 有任何疑惑可以回复我~ 2019-03-23 16:39:13
  • 老师,我的在appium上显示的是乱码(就是把我text上的请输入密码解读为乱码了),和楼主提的问题一样,然后Python上控制台显示timeout
    回复 有任何疑惑可以回复我~ 2019-03-23 16:51:57
  • 因为我问题和楼主提的一模一样,但是您说的找个乱码处理一下,appium把我text内容:请输入密码 解读为乱码了,但是不知道咋处理这个乱码
    回复 有任何疑惑可以回复我~ 2019-03-23 16:55:25
Mushishi 2018-05-15 12:01:28

你好,你看: info: [debug] [BOOTSTRAP] [debug] Finding //*[contains(@text,u'璇疯緭鍏ュ瘑鐮?)] using XPATH with the contextId:  multiple: false 提示已经没找到了,这个你去找个乱码,你处理一下

0 回复 有任何疑惑可以回复我~
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信