[英]Why we need javaScript executor for webdriver?
Can one please help me to know why we exactly need JavaScriptExecutor for Webdriver? 可以帮助我知道为什么我们对于Webdriver确实需要JavaScriptExecutor吗?
I have seen few examples using JavascriptExecutor to mouse hover, to click on any elements which can also be done normally with Webdriver. 我看到了几个使用JavascriptExecutor鼠标悬停来单击任何元素的示例,这些元素也可以使用Webdriver正常完成。
And there are cases which i have seen is when the element is disabled, using JavascriptExecutor clicking on that element. 在某些情况下,使用JavascriptExecutor单击该元素可以禁用该元素。 Why we need to perform any operations on disabled elements (to user on FrontEnd). 为什么我们需要对禁用的元素执行任何操作(前端用户)。
It is actually a nice question. 这实际上是一个很好的问题。
Selenium is basically solve simple java script event problem. Selenium基本上是解决简单的Java脚本事件的问题。
But when we need to test application at Industry level, We require to write JQuery as well as Java script. 但是,当我们需要在行业级别测试应用程序时,我们需要编写JQuery和Java脚本。
For EG In some website there is some restriction like double click or right click or selection. 对于EG在某些网站上有一些限制,例如双击或右键单击或选择。
In this cases we have to write java script with "JavascriptExecutor". 在这种情况下,我们必须使用“ JavascriptExecutor”编写Java脚本。
As per my understanding you want to ask why "JavascriptExecutor" is perform event on disable element? 根据我的理解,您想问为什么“ JavascriptExecutor”在disable元素上执行事件?
In answer , I want to say it is may be a test case requirement. 答案是,我想说这可能是一个测试用例的要求。
You may be think why we need to write javascript for selenium in built method? 您可能会想到为什么我们需要使用内置方法为硒编写javascript?
So selenium provide both way that you are prefer.But With "Action" we have to call inbuilt Java functions which are integrate with mouse. 因此,硒提供了您偏爱的两种方式。但是使用“动作”,我们必须调用与鼠标集成的内置Java函数。 And With "JavascriptExecutor" we have our implementation with modified code. 借助“ JavascriptExecutor”,我们可以使用修改后的代码来实现我们的实现。
This is main Advantage over inbuilt functions. 这是优于内置功能的主要优势。
:) :)
If you have any query comment me. 如果您有任何疑问,请评论我。
Thank You. 谢谢。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.