Selenium,无法单击 DEVOPS 上的元素
我在页面上有 FontAwesomeIcon 反应元素。当我在本地运行测试时,它通常可以工作,这意味着它找到元素并执行单击操作。 当我在 DevOps 测试中运行相同的场景时,它不可交互。 我尝试以多种方式运行点击操作,但没有任何效果。 代码
IWebElement btnSearchLocalization = driver.FindElement(By.CssSelector(".fa-1x"));
executorEventPlace.ExecuteScript("arguments[0].scrollIntoView(true);", btnSearchLocalization);
IWebElement btnSearchLocalization2 = driver.FindElement(By.CssSelector(".fa-1x"));
btnSearchLocalization2.Click();
我在交互元素方面遇到了很多其他问题,但在大多数情况下帮助了这两个解决方案之一:
executorEventPlace.ExecuteScript("arguments[0].scrollIntoView(true);", eventPlace);
executorEventPlace.ExecuteScript("arguments[0].click();", eventPlace);
如何正确设置 devops 代理?如何与我本地电脑进行比较?我还添加了很多 Thread.Sleep() ,但这些元素必须是可见的。
编辑 初始化:
public static IWebDriver _driver;
public static IWebDriver Instance
{
get
{
if (_driver == null)
{
ChromeOptions options = new ChromeOptions();
//options.AddArguments("start-maximized");
//options.AddArguments("--window-size=1920,1080");
options.AddArguments("--start-maximized");
options.AddArgument("--ignore-certificate-errors");
options.AddArgument("--disable-popup-blocking");
options.AddArgument("--incognito");
_driver = new ChromeDriver(@"C:\temp\chromedriver\", options);
//_driver = new ChromeDriver(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), options);
}
return _driver;
}
}
异常: OpenQA.Selenium.ElementNotInteractableException:元素不可交互:元素当前不可见,并且可能无法操作 (会话信息:chrome=99.0.4844.84)
I have FontAwesomeIcon react element on page. When I run tests locally it normally works it means it finds element and do Click action.
When I am running the same scenarious in devops tests it is not interactable.
I tried to run click action in a lot of ways but nothing works.
CODE
IWebElement btnSearchLocalization = driver.FindElement(By.CssSelector(".fa-1x"));
executorEventPlace.ExecuteScript("arguments[0].scrollIntoView(true);", btnSearchLocalization);
IWebElement btnSearchLocalization2 = driver.FindElement(By.CssSelector(".fa-1x"));
btnSearchLocalization2.Click();
I got a lot of other problems with interacting elements but in most of cases helped one of this two solutions:
executorEventPlace.ExecuteScript("arguments[0].scrollIntoView(true);", eventPlace);
executorEventPlace.ExecuteScript("arguments[0].click();", eventPlace);
How to setup devops agent correctly? How to compare it with my local computer? I also added a lot of Thread.Sleep()
but this elements must be visible.
Edit
Initialization:
public static IWebDriver _driver;
public static IWebDriver Instance
{
get
{
if (_driver == null)
{
ChromeOptions options = new ChromeOptions();
//options.AddArguments("start-maximized");
//options.AddArguments("--window-size=1920,1080");
options.AddArguments("--start-maximized");
options.AddArgument("--ignore-certificate-errors");
options.AddArgument("--disable-popup-blocking");
options.AddArgument("--incognito");
_driver = new ChromeDriver(@"C:\temp\chromedriver\", options);
//_driver = new ChromeDriver(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), options);
}
return _driver;
}
}
Exception:
OpenQA.Selenium.ElementNotInteractableException : element not interactable: Element is not currently visible and may not be manipulated
(Session info: chrome=99.0.4844.84)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论