我有一个画布,我需要按CTRL + SHIFT + V.当我按下这些键时,会弹出一个窗口,我必须从中读取文字。
我使用的是IE11和.Net。问题在于使用硒网格。
我尝试了这个,但它不起作用。任何线索?
Canvas.SendKeys(Keys.Control + Keys.Shift + "V")
我也尝试使用v \ u0056的ascii值,但这似乎也不起作用。
添加了复制问题的完整方法。
public void TestMethod1()
{
DesiredCapabilities cap = DesiredCapabilities.InternetExplorer();
// When set the HasNativeEvents the send keys works fine but that is a restriction i can't do that.
//cap.SetCapability(CapabilityType.HasNativeEvents, false);
webdriver = new RemoteWebDriver(new Uri("http://someip:port/wd/hub"), cap);
webdriver.Manage().Timeouts().ImplicitlyWait(new TimeSpan(0, 0, 30));
webdriver.Navigate().GoToUrl("http://someip:port");
webdriver.FindElement(By.LinkText("OpenCanvas")).Click();
IWebElement ele = webdriver.FindElement(By.Id("canvasID"));
Actions action = new Actions(webdriver);
Thread.Sleep(2000);
ele.SendKeys(Keys.Control + Keys.Shift + 'v'); // this should open a pop up but it fails
Thread.Sleep(5000);
string after_markup = webdriver.FindElement(By.Id("DialogText")).Text;
Assert.AreEqual("some test string", after_markup, "Failed to draw markup on 3D model");
}
答案 0 :(得分:1)
在研究如何在C#中发送多个密钥时,看起来如果你传递了字符串" V"作为一个小写" v",它应该工作。
所以试试:
Canvas.SendKeys(Keys.Control + Keys.Shift + "v");
希望对你有用。