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)
目录
相关文章
|
3月前
|
Web App开发 数据采集 Java
【Python】已完美解决:selenium.common.exceptions.SessionNotCreatedException: Message: session not created
【Python】已完美解决:selenium.common.exceptions.SessionNotCreatedException: Message: session not created
360 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.
1062 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.
|
3月前
|
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
422 6
|
5月前
|
IDE 开发工具 Python
selenium.common.exceptions.NoSuchDriverException: Message: Unable to obtain driver for MicrosoftEdge
selenium.common.exceptions.NoSuchDriverException: Message: Unable to obtain driver for MicrosoftEdge
508 3
|
Web App开发 Python Windows
selenium.common.exceptions.WebDriverException: Message: session not created(已解决)
selenium.common.exceptions.WebDriverException: Message: session not created(已解决)
129 0
|
Web App开发
selenium.common.exceptions.WebDriverException: Message: unable to set cookie
selenium.common.exceptions.WebDriverException: Message: unable to set cookie
410 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
473 0
Appium问题解决方案(5)- selenium.common.exceptions.InvalidSelectorException: Message: Locator Strategy 'name' is not supported for this session
|
11天前
|
Web App开发 前端开发 JavaScript
探索Python科学计算的边界:利用Selenium进行Web应用性能测试与优化
【10月更文挑战第6天】随着互联网技术的发展,Web应用程序已经成为人们日常生活和工作中不可或缺的一部分。这些应用不仅需要提供丰富的功能,还必须具备良好的性能表现以保证用户体验。性能测试是确保Web应用能够快速响应用户请求并处理大量并发访问的关键步骤之一。本文将探讨如何使用Python结合Selenium来进行Web应用的性能测试,并通过实际代码示例展示如何识别瓶颈及优化应用。
42 5
|
14天前
|
Java 测试技术 C#
自动化测试之美:从Selenium到Appium
【10月更文挑战第3天】在软件开发的海洋中,自动化测试如同一艘航船,引领着质量保证的方向。本文将带你领略自动化测试的魅力,从Web端的Selenium到移动端的Appium,我们将一探究竟,看看这些工具如何帮助我们高效地进行软件测试。你将了解到,自动化测试不仅仅是技术的展示,更是一种提升开发效率和产品质量的智慧选择。让我们一起启航,探索自动化测试的世界!
|
11天前
|
JavaScript 前端开发 测试技术
精通Selenium:从基础到高级的网页自动化测试策略
【10月更文挑战第6天】随着Web应用变得越来越复杂,手动进行功能和兼容性测试变得既耗时又容易出错。自动化测试因此成为了现代软件开发不可或缺的一部分。Selenium是一个强大的工具集,它支持多种编程语言(包括Python),允许开发者编写脚本来模拟用户与Web页面的交互。本文将带领读者从Selenium的基础知识出发,逐步深入到高级的应用场景,通过丰富的代码示例来展示如何高效地进行网页自动化测试。
33 5