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)
目录
相关文章
|
2月前
|
Web App开发 数据采集 Java
【Python】已完美解决:selenium.common.exceptions.SessionNotCreatedException: Message: session not created
【Python】已完美解决:selenium.common.exceptions.SessionNotCreatedException: Message: session not created
239 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.
1031 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.
|
2月前
|
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
184 6
|
4月前
|
IDE 开发工具 Python
selenium.common.exceptions.NoSuchDriverException: Message: Unable to obtain driver for MicrosoftEdge
selenium.common.exceptions.NoSuchDriverException: Message: Unable to obtain driver for MicrosoftEdge
466 3
|
Web App开发 Python Windows
selenium.common.exceptions.WebDriverException: Message: session not created(已解决)
selenium.common.exceptions.WebDriverException: Message: session not created(已解决)
124 0
|
Web App开发
selenium.common.exceptions.WebDriverException: Message: unable to set cookie
selenium.common.exceptions.WebDriverException: Message: unable to set cookie
404 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
463 0
Appium问题解决方案(5)- selenium.common.exceptions.InvalidSelectorException: Message: Locator Strategy 'name' is not supported for this session
|
11天前
|
Web App开发 Java 测试技术
自动化测试的利器:Selenium WebDriver入门与实践
【9月更文挑战第8天】在软件开发的海洋中,测试是确保我们不会溺水的那根救生索。Selenium WebDriver,作为自动化测试的明星工具,让这根救生索更加结实可靠。本文将带你快速上手Selenium WebDriver,从基础设置到实际操作,再到实战演练,让你的开发之旅更加平稳顺畅。
|
5天前
|
敏捷开发 Java 测试技术
探索自动化测试的奥秘:从Selenium到Appium
【9月更文挑战第14天】软件测试,这个看似枯燥乏味却至关重要的领域,正经历着一场革命。随着技术的进步,自动化测试工具如Selenium和Appium已成为质量保证的利器。本文将带你一探这些工具的神秘面纱,了解它们如何简化测试流程、提升效率,并确保软件产品的质量。准备好,我们将深入自动化测试的世界,解锁其背后的原理和实践技巧。
|
6天前
|
敏捷开发 测试技术 持续交付
自动化测试之美:如何用Selenium和Python打造高效测试脚本
【9月更文挑战第13天】在软件开发的海洋中,自动化测试是那抹不可或缺的亮色。它不仅提升了测试效率,还保障了产品质量。本文将带你领略使用Selenium和Python构建自动化测试脚本的魅力所在,从环境的搭建到脚本的编写,再到问题的排查,每一步都是对软件质量把控的深刻理解和实践。让我们开始这段探索之旅,解锁自动化测试的秘密吧!
8 0