我遇到了此解决方案,这是我最初遇到的问题使用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的最佳实践是什么
发布评论