Open GoogleCodeExporter opened 9 years ago
Unfortunately sending a native key combination doesn't work with the Selenium
.Net framework.
Refer to : https://code.google.com/p/selenium/issues/detail?id=4965
Anyway, I will implement the Actions class for the next release. It should work
like this :
element = driver.findElementById("id)
driver.Actions.keyDown(Keys.Control, element).sendKeys("s", element).perform();
I will also add a native keyboard class to send keys to a window and a native
mouse class to click anywhere.
Original comment by florentbr
on 11 Oct 2013 at 2:13
There's a way to simulate key inputs with the WScript.Shell library.
Here is an example :
Dim shell: Set WshShell = CreateObject("WScript.Shell")
Dim driver As New SeleniumWrapper.WebDriver
driver.Start "firefox", "http://www.google.com"
driver.setImplicitWait 5000
driver.Open "/"
shell.SendKeys "^s" 'Send Ctrl+s to Firefox which opens the "Save as" dialogue
box
Original comment by florentbr
on 11 Oct 2013 at 12:03
hello and thanks for your answer.
Regarding your code , I have tried it but how do you reference the shell
library.
I am getting an error , please see the attachement.
Thanks for your help.
Original comment by alam...@gmail.com
on 12 Oct 2013 at 10:16
here is the attachement
Original comment by alam...@gmail.com
on 12 Oct 2013 at 10:17
Attachments:
My mistake, the object variable is not the one used to call SendKeys.
The correct code:
Sub TestShell()
Dim shell: Set shell = CreateObject("WScript.Shell")
Dim driver As New SeleniumWrapper.WebDriver
driver.Start "firefox", "http://www.google.com"
driver.setImplicitWait 5000
driver.Open "/"
shell.SendKeys "^s" 'Send Ctrl+s to Firefox which opens the "Save as" dialogue box
End Sub
Original comment by florentbr
on 12 Oct 2013 at 1:43
Works fine , thank you :)
the idea behind the ctrl + s is to have the save the webpage (works fine with
firefox) so a save as window is displayed , is there a way to simulate the
enter so that it save the page , here the code trigger the save as window and
nothing happened after.
Thanks
Original comment by alam...@gmail.com
on 12 Oct 2013 at 2:48
The documentation for the SendKeys command :
http://msdn.microsoft.com/en-us/library/8c6yea83(v=vs.84).aspx
In your case I would do :
shell.SendKeys "^s"
shell.Sleep 1000
shell.SendKeys "{ENTER}"
Original comment by florentbr
on 12 Oct 2013 at 3:00
I tried it ineed before , but nothing happened with
shell.SendKeys "{ENTER}"
regarding shell.sleep 1000 , i am not sure it is supported.
Thanks
Original comment by alam...@gmail.com
on 12 Oct 2013 at 3:15
You're right, it's not supported.
The correct code is:
shell.SendKeys "^s"
driver.Wait 1000
shell.SendKeys "pagename.htm{ENTER}"
Original comment by florentbr
on 13 Oct 2013 at 6:25
Thanks , it does work fine now :)
Original comment by alam...@gmail.com
on 13 Oct 2013 at 9:57
Original comment by florentbr
on 8 Sep 2014 at 5:37
Original issue reported on code.google.com by
alam...@gmail.com
on 9 Oct 2013 at 8:58