gpt4 book ai didi

java - 无法在 appium 中的 twitter LoginPage 上找到元素

转载 作者:行者123 更新时间:2023-12-01 23:39:56 25 4
gpt4 key购买 nike

Twitter Login Page via appium desktop

我正在尝试使用 appium 在 twitter 登录页面上定位“登录”,但我看到“已经有帐户?登录”位于一个定位器下,并且正如预期的那样,该定位器不接受 appium 桌面的“点击”操作以及。

因此,我无法在 appium 中自动执行 twitter 登录操作。

有人可以建议如何做同样的事情吗?

最佳答案

如果按坐标点击在Appium Inspector中对元素起作用(不仅仅是常规点击,选择元素,而是按坐标点击,点击绝对位置),那么您可以使用该解决方案点击登录文本。

首先,我们要找到该元素,然后移动一个小的 x 轴偏移(大约 20 像素)到“登录”链接。

根据您使用的语言,您可以使用 TouchActions 类来完成此操作:

// get the web element for link
IWebElement logInLink = driver.FindElement(By.XPath("//*[contains(@text, 'Log in')]"));

// get the x,y coordinates for the link
int xCoordinate = logInLink.Coordinates.LocationOnScreen.X;
int yCoordinate = logInLink.Coordinates.LocationOnScreen.Y;

// perform action that moves to coordinates, and taps 20 pixels to the right
new TouchAction(driver).MoveTo(xCoordinate + 20, yCoordinate).Press().Release().Perform();

您可能需要在此处使用偏移值 + 20 并尝试 1030 等。您也可以在 Appium 检查器中使用“按坐标点击”获取坐标位置,然后调试代码以获取 WebElement 的坐标,并调整偏移量以使元素的 x 坐标与所需点击位置的 x 坐标相匹配。

关于java - 无法在 appium 中的 twitter LoginPage 上找到元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58264366/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com