python timeoutexception_获取不到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 

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: 

> 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: 

> 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: 

> 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.

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值