gpt4 book ai didi

selenium - PhantomJS 无法使用 selenium webdriver 找到该元素

转载 作者:行者123 更新时间:2023-12-02 19:28:46 26 4
gpt4 key购买 nike

我有一个 Selenium Web 驱动程序脚本,它仅访问 Web 元素(文本框)并将其值设置为某个值。

我使用 ChutzPath 因为它在后端使用 PhantomJS 浏览器。

但是每次执行脚本时,都会显示以下错误。

T
Result Message:
Test method Test_Project_with_Selenium.UnitTest1.BrowseTheWeb threw exception:

OpenQA.Selenium.NoSuchElementException: Error Message => 'Unable to find element with id 'inputEl''
***caused by Request => {"headers":{"Accept":"application/json, image/png","Connection":"Close","Content-Length":"47","Content-Type":"application/json;charset=utf-8","Host":"localhost:42982"},"httpVersion":"1.1","method":"POST","post":"{\"using\":\"id\",\"value\":\"textfield-1042-inputEl\"}","url":"/element","urlParsed":{"anchor":"","query":"","file":"element","directory":"/","path":"/element","relative":"/element","port":"","host":"","password":"","user":"","userInfo":"","authority":"","protocol":"","source":"/element","queryKey":{},"chunks":["element"]},"urlOriginal":"/session/01225660-1a45-11e3-8ea4-eff85782779d/element"}
Result StackTrace:
at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
at OpenQA.Selenium.Remote.RemoteWebDriver.FindElement(String mechanism, String value)
at OpenQA.Selenium.Remote.RemoteWebDriver.FindElementById(String id)
at Test_Project_with_Selenium.UnitTest1.BrowseTheWebClient() in c:\Users\XYZ\Documents\Visual Studio 2012\Projects\ProjectName\Test_Project_with_Selenium\UnitTest1.cs:line 19***

最佳答案

不确定这里是否是这种情况,因为问题不是很具体,但我遇到的一件事是 PhantomJS 1.9.7 需要该位置中的 HTTP 方案。

因此,如果您要导航 localhost:42982/element,您应该指定要导航到 http://localhost:42982/element 的驱动程序.

关于selenium - PhantomJS 无法使用 selenium webdriver 找到该元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18726458/

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