获取不到toast,提示selenium.common.exceptions.TimeoutException: Message:
来源:1-19 如何获取tost元素
慕雪7554485
2018-05-14
# -*- 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.写回答
2回答
-
慕姐1291937
2019-03-22
你好,请问下您的问题解决没呢?我也遇到了一样的问题,怎么弄都解决不了
062019-03-25 -
Mushishi
2018-05-15
你好,你看: info: [debug] [BOOTSTRAP] [debug] Finding //*[contains(@text,u'璇疯緭鍏ュ瘑鐮?)] using XPATH with the contextId: multiple: false 提示已经没找到了,这个你去找个乱码,你处理一下
032018-07-21
相似问题