使用Selenium WebDriver模拟ENTER或RETURN的最佳实践是什么

编程入门 行业动态 更新时间:2024-10-10 11:23:55
本文介绍了使用Selenium WebDriver模拟ENTER或RETURN的最佳实践是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我遇到了此解决方案,这是我最初遇到的问题使用Selenium WebDriver模拟ENTER或RETURN键.

I came across this solution to my initial problem, which was to simulate an ENTER or RETURN key press using Selenium WebDriver.

但是,在我的代码中,我严格只想使用两个WebElement.sendKeys(Keys.ENTER); vs WebElement.sendKeys(Keys.RETURN);之一.

However, in my code, I strictly want to use only one of the two WebElement.sendKeys(Keys.ENTER); vs WebElement.sendKeys(Keys.RETURN);.

进行相同操作时的最佳实践是什么,因为对于使用enter或return似乎存在分歧,因为两者都在同一时间工作?在哪种情况下,一种或另一种都不起作用,有没有一种总是可行的?

What is the best practice when doing the same, since there seems to be divided opinion about using enter or return, since both work MOST of the time? In what scenarios would one or the other not work, and is there one which would ALWAYS work?

推荐答案

就性能而言,我在这两个方面都没有任何改变,

As a performancewise I do not get any change on both of these,

但是是的,我知道他们之间的区别

But yes I know one difference on them

Keys.Enter用于在数字键盘上输入键

Keys.Enter is used to enter key on the number pad

同时

Keys.Return用于字母旁边的一个

通常我更喜欢Keys.Enter,因为有时在某些浏览器中Keys.Return对我不起作用

Generally I have preferred Keys.Enteras sometimes in some browser Keys.Return is not worked for me

更多推荐

使用Selenium WebDriver模拟ENTER或RETURN的最佳实践是什么

本文发布于:2023-11-27 22:43:22,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1639905.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:WebDriver   Selenium   RETURN   ENTER

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!