Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 用C按Selenium RC中的Enter键#_C#_Selenium_Selenium Rc_Keypress_Enter - Fatal编程技术网

C# 用C按Selenium RC中的Enter键#

C# 用C按Selenium RC中的Enter键#,c#,selenium,selenium-rc,keypress,enter,C#,Selenium,Selenium Rc,Keypress,Enter,如何使用C#使用Selenium RC按Enter键 我正在使用Selenium使用SearchBox。 我必须在其中键入一些名称,然后按Enter键进行搜索 没有Submit按钮。所以,我必须使用回车键 我试过这样的东西 selenium.KeyPress("quicksearchtextcriteria", "13"); 但是不起作用 请帮忙 注意:我收集了一些可能的方法。请参见此处:尝试以下操作: selenium.KeyPressNative("13"); 用这个 selenium.

如何使用C#使用Selenium RC按Enter键

我正在使用
Selenium
使用
SearchBox
。 我必须在其中键入一些名称,然后按Enter键进行搜索

没有
Submit
按钮。所以,我必须使用回车键

我试过这样的东西

selenium.KeyPress("quicksearchtextcriteria", "13");
但是不起作用

请帮忙

注意:我收集了一些可能的方法。请参见此处:

尝试以下操作:

selenium.KeyPressNative("13");
用这个

selenium.keyDown("locator of element", "\\13");
这可以通过和实现

Java中的示例,我不知道C#:


我相信您也可以使用“提交”方法。(虽然我使用Selenium 2,但我猜这在Selenium RC中可能是不可能的?如果是的话,很抱歉)

您可以使用clickAt(“定位器”);如果按键不起作用。它肯定会起作用。

试试这个:

selenium.KeyPressNative("13");

导入org.openqa.selenium.Keys

WebElement.sendKeys(Keys.RETURN)

参考文献:

希望这能有所帮助。

这就是C#的用法:


webElement.SendKeys(key.Return)

请注意,为什么不使用selenium 2?导入org.openqa.selenium.Keys;这本身就是一个错误。我在VisualStudio工作。哦,对不起,我的错。那是Java,我没有从代码片段中认出C。C#难道没有其他选择吗?也许不行,我不知道。c#alternative的链接不起作用。是否有一个c#替代品来代替这个{code}selenium.type(“locator”,“Any text”+Keys.ENTER);{code}错误链接的错误消息是:在此服务器上找不到请求的URL/svn/trunk/docs/api/dotnet/html/T_OpenQA_Selenium_Keys.htm。我们只知道这些,我修复了链接。请注意,这个答案已经有6年历史了,Selenium RC已经过时了。去找WebDriver!这里的元素定位器是什么意思?dat是我的文本框的xpath吗?是的,把文本框的xpath放进去。我试过了,但没用。没有错误。但当我调试它时,Enter不起作用,它表示表达式已计算但没有值。quicksearchtextcriteria是字段的ID???如果是,则尝试使用locator作为ID=quicksearchtextcriteria…我认为这是xpath错误消息或:searchBox.SendKeys(“要搜索的文本”+OpenQA.Selenium.Keys.Enter);尝试此操作时,Visual Studio 2017中出现以下错误:“参数1无法从“System.Windows.Forms.Keys”转换为“string”-API SendKeys需要字符串。
//First you need to find the searchBox and fill it, once doing so call
searchBox.Submit();