Selenium webdriver.remote()可以单击元素
我正在使用
Selenium Remote Webdriver 对 django项目进行测试。我有几个Docker容器,这就是为什么我需要使用远程驱动程序的原因。
在我的测试中,我的硒配置如下:
# Inside setUp() method from Django's TestCase
self.firefox_options = webdriver.FirefoxOptions()
self.driver = webdriver.Remote(
command_executor="http://develop-tandem-marianao-selenium:4444",
options=self.firefox_options,
)
self.driver.implicitly_wait(2)
问题
是,硒和django项目容器已正确连接,我可以执行测试,但是每当我尝试comply> click> click> click> click> click> comece()
方法方法方法,但是我会发现错误
Element <...> could not be scrolled into view
,通过搜索,我发现这样做
self.driver.execute_script("arguments[0].click();", element)
确实有效。我在某个地方读到,当Selenium尝试consc> click()
时,网站的某些部分尚未加载可能是一个问题,但这仍然没有告诉我该怎么做。
有什么想法吗?
编辑:我还尝试强迫测试等待(使用time.sleep()
),但仍然不起作用。
Situation
I'm using the Selenium Remote webdriver to do my tests on a Django project. I have several Docker containers, which is why I needed to use the Remote driver.
In my test, my Selenium configuration is as follows
# Inside setUp() method from Django's TestCase
self.firefox_options = webdriver.FirefoxOptions()
self.driver = webdriver.Remote(
command_executor="http://develop-tandem-marianao-selenium:4444",
options=self.firefox_options,
)
self.driver.implicitly_wait(2)
Problem
Thing is, the Selenium and Django project containers are connected properly and I am able to perform tests, but whenever I try the click()
method on any element, I get the error
Element <...> could not be scrolled into view
However, by searching around I found out that doing
self.driver.execute_script("arguments[0].click();", element)
instead does work. I've read somewhere that it might be a problem that some part of the website is not loaded yet when Selenium attempts to click()
, but that still doesn't tell me what to do.
Any ideas?
Edit: I've also tried forcing the test to wait (with time.sleep()
) and it still doesn't work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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