Selenium-为什么最小化浏览器会导致找不到元素错误,而max却没有 [英] Selenium -Why does minimized browser give element not found error whereas max doesn't

查看:1035
本文介绍了Selenium-为什么最小化浏览器会导致找不到元素错误,而max却没有的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Selenium 2.0,据我所知,Selenium并不真正在乎您的浏览器的大小.但是,当我单击一个下拉菜单时,似乎无法在浏览器视图中找不到所有元素,而当浏览器视图最大化时,它可以找到.

I am working with Selenium 2.0 and as far I thought, Selenium doesn't really care about the size of your browser. But when I click a dropdown menu, it can't seem to find all the elements not in the view of the browser whereas when its maxed out it can.

我个人认为它是通过网络脚本爬网的,但是我的观察证明我错了.

I personally thought it crawls through the web script but my observations prove me wrong.

评论?

推荐答案

您对Selenium内部工作的假设对于Selenium RC是正确的,Selenium RC是Selenium 1.0中使用的基于JavaScript的技术.但是,由于完全基于JavaScript,这意味着它仅限于浏览器的JavaScript沙箱,从而阻止了浏览器中的某些操作.

Your assumptions about the inner workings of Selenium may have been correct for Selenium RC, which was a JavaScript-based technology used in Selenium 1.0. Being entirely JavaScript-based, however, meant that it was limited to the browser's JavaScript sandbox, which precluded some actions in the browser.

Selenium 2.0引入了Selenium WebDriver,它是Web自动化的另一范式. WebDriver尝试尽可能紧密地模拟用户体验和操作.由于建模用户体验决定了与元素交互的某些设计和技术选择,因此,如果最小化浏览器,则可能无法正常工作,因为在最小化浏览器窗口的同时,用户无法与页面进行交互.

Selenium 2.0 introduced Selenium WebDriver, which is a different paradigm of web automation. WebDriver attempts to model the user experience and actions as closely as possible. Since modeling the user experience dictates certain design and technology choices for interacting with elements, it likely won't work if the browser is minimized, since a user cannot interact with the page while the browser window is minimized.

顺便说一句,如果查找元素是执行WebDriver代码的问题,我会感到惊讶.与找到的元素进行交互,例如尝试单击它们或向其发送击键,我完全希望这样做会失败.

Incidentally, I'd be surprised if finding the elements was the issue with executing WebDriver code. Interacting with the elements found, like attempting to click on them or send keystrokes to them, I would completely expect that to fail.

这篇关于Selenium-为什么最小化浏览器会导致找不到元素错误,而max却没有的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆