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)
目录
相关文章
|
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.
1134 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.
|
5月前
|
Web App开发 数据采集 Java
【Python】已完美解决:selenium.common.exceptions.SessionNotCreatedException: Message: session not created
【Python】已完美解决:selenium.common.exceptions.SessionNotCreatedException: Message: session not created
524 0
|
5月前
|
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
674 6
|
7月前
|
IDE 开发工具 Python
selenium.common.exceptions.NoSuchDriverException: Message: Unable to obtain driver for MicrosoftEdge
selenium.common.exceptions.NoSuchDriverException: Message: Unable to obtain driver for MicrosoftEdge
621 3
|
7月前
selenium.common.exceptions.InvalidElementStateException: Message: Unable to perform W3C actions.
selenium.common.exceptions.InvalidElementStateException: Message: Unable to perform W3C actions.
107 0
|
Web App开发 Python Windows
selenium.common.exceptions.WebDriverException: Message: session not created(已解决)
selenium.common.exceptions.WebDriverException: Message: session not created(已解决)
139 0
Gradle sync failed: Unsupported method: NativeArtifact.getSourceFolders().
Gradle sync failed: Unsupported method: NativeArtifact.getSourceFolders().
105 0
|
Web App开发
selenium.common.exceptions.WebDriverException: Message: unable to set cookie
selenium.common.exceptions.WebDriverException: Message: unable to set cookie
422 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
498 0
Appium问题解决方案(5)- selenium.common.exceptions.InvalidSelectorException: Message: Locator Strategy 'name' is not supported for this session
|
Android开发
A failure occurred while executing com.android.build.gradle.tasks.MergeResources$FileGenerationWorkA
A failure occurred while executing com.android.build.gradle.tasks.MergeResources$FileGenerationWorkA
A failure occurred while executing com.android.build.gradle.tasks.MergeResources$FileGenerationWorkA