selenium.common.exceptions.InvalidElementStateException Message Unable to perform W3C actions

简介: selenium.common.exceptions.InvalidElementStateException Message Unable to perform W3C actions

Appium滑动元素时,报错:


selenium.common.exceptions.InvalidElementStateException: Message: Unable to perform W3C actions. Check the logcat output for possible error reports and make sure your input actions chain is valid.


在使用Appium进行swipe()滑动操作时,提示:


selenium.common.exceptions.InvalidElementStateException: Message: Unable to perform W3C actions. Check the logcat output for possible error reports and make sure your input actions chain is valid.


解决方案


InvalidElementStateException,通常与元素状态有关,所以在滑动之前,要等待元素变得可见和可交互。


因此,只需操作滑动元素之前,添加等待即可。

def test_swipe_to():
    from driver.appium.webdriver import Webdriver
    appium_server_url = 'http://localhost:4723'
    capabilities = {
        "platformName": "Android",
        "automationName": "uiautomator2",
        "deviceName": "127.0.0.1:62001",
        "app": "D:\\resources\\imooc.apk",
    }
    driver = Webdriver(command_executor=appium_server_url, capabilities=capabilities)
    time.sleep(3)  # 等待页面加载完成之后,再滑动页面
    driver.swipe_to('left', n=2)
    driver.swipe_to('right', n=3)
目录
相关文章
|
6月前
|
消息中间件
mq安装出现的问题 Unable to load crypto library. Failed with error:
mq安装出现的问题 Unable to load crypto library. Failed with error:
165 0
|
Java
Appium问题解决方案(8)- selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: Could not sign with default certificate.
Appium问题解决方案(8)- selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: Could not sign with default certificate.
1090 0
Appium问题解决方案(8)- selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: Could not sign with default certificate.
|
4月前
|
Web App开发 测试技术 Python
【Python】已解决:selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrom
【Python】已解决:selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrom
535 6
|
6月前
|
开发工具
App Store Connect Operation Error ERROR ITMS-90087: “Unsupported Architectures
App Store Connect Operation Error ERROR ITMS-90087: “Unsupported Architectures
53 1
|
6月前
|
IDE 开发工具 Python
selenium.common.exceptions.NoSuchDriverException: Message: Unable to obtain driver for MicrosoftEdge
selenium.common.exceptions.NoSuchDriverException: Message: Unable to obtain driver for MicrosoftEdge
567 3
|
6月前
selenium.common.exceptions.InvalidElementStateException: Message: Unable to perform W3C actions.
selenium.common.exceptions.InvalidElementStateException: Message: Unable to perform W3C actions.
96 0
|
Web App开发 Python Windows
selenium.common.exceptions.WebDriverException: Message: session not created(已解决)
selenium.common.exceptions.WebDriverException: Message: session not created(已解决)
135 0
报错解决:Reason: Failed to determine a suitable driver class
报错解决:Reason: Failed to determine a suitable driver class
2551 0
报错解决:Reason: Failed to determine a suitable driver class
|
Web App开发
selenium.common.exceptions.WebDriverException: Message: unable to set cookie
selenium.common.exceptions.WebDriverException: Message: unable to set cookie
415 0
|
测试技术
Appium问题解决方案(5)- selenium.common.exceptions.InvalidSelectorException: Message: Locator Strategy 'name' is not supported for this session
Appium问题解决方案(5)- selenium.common.exceptions.InvalidSelectorException: Message: Locator Strategy 'name' is not supported for this session
483 0
Appium问题解决方案(5)- selenium.common.exceptions.InvalidSelectorException: Message: Locator Strategy 'name' is not supported for this session