Press control+F5 using webdriver

5,569 views
Skip to first unread message

Mattayi

unread,
Nov 30, 2011, 7:31:35 AM11/30/11
to webdriver
I am using webdriverbackedselenium. My requirement is to press control
+ F5 such as to clear my cache. Is there any method provided by
selenium or webdriver to do so. Also it will great if the key press
events are independent of any other page elements.

I read somewhere that java Robot class can be used to simulate this.
But this always does for whichever window that has focus.

Leonardo Galani

unread,
Nov 30, 2011, 7:43:48 AM11/30/11
to webd...@googlegroups.com

close and open again the browser to kill the cache. (stop / start)


Att
Leonardo Barba Galani
Tester!
Java, Selenium e Coca Cola (http://www.leonardobg.com.br)

>--
>You received this message because you are subscribed to the Google Groups "webdriver" group.
>To post to this group, send email to webd...@googlegroups.com.
>To unsubscribe from this group, send email to webdriver+...@googlegroups.com.
>For more options, visit this group at http://groups.google.com/group/webdriver?hl=en.

Krishnan Mahadevan

unread,
Nov 30, 2011, 8:00:55 AM11/30/11
to webd...@googlegroups.com
Mathew,
Since you would be having an instance of WebDriver even though you have instantiated WebDriverBackedSelenium,
maybe you can use the WebDriver instance and use

new Actions(driver).keyDown(Keys.CONTROL).keyDown(Keys.F5).keyUp(Keys.CONTROL).keyUp(Keys.F5).perform();

I havent tested this to ascertain that this is working fine, but am guessing that this should work.

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"

Mark Collin

unread,
Nov 30, 2011, 9:02:05 AM11/30/11
to webd...@googlegroups.com
You could try:

Actions actionObject = new Actions(driver);

actionObject.keyDown(Keys.CONTROL).keyDown(Keys.F5).keyUp(Keys.CONTROL).keyU
p(Keys.F5).perform();

-----Original Message-----
From: webd...@googlegroups.com [mailto:webd...@googlegroups.com] On
Behalf Of Mattayi
Sent: 30 November 2011 12:32
To: webdriver
Subject: [webdriver] Press control+F5 using webdriver

--


You received this message because you are subscribed to the Google Groups
"webdriver" group.
To post to this group, send email to webd...@googlegroups.com.
To unsubscribe from this group, send email to
webdriver+...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/webdriver?hl=en.


--
This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. If you are not the intended recipient you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited.

If you have received this email in error please notify postm...@ardescosolutions.com

Robert

unread,
Nov 30, 2011, 9:32:22 AM11/30/11
to webd...@googlegroups.com
Krishnan,

When I attempt to use the example code, I get the following...what does this mean?


java.lang.IllegalArgumentException: Key Down / Up events only make sense for modifier keys.
at org.openqa.selenium.interactions.internal.SingleKeyAction.<init>(SingleKeyAction.java:46)
at org.openqa.selenium.interactions.KeyDownAction.<init>(KeyDownAction.java:32)
at org.openqa.selenium.interactions.Actions.keyDown(Actions.java:98)
at org.openqa.selenium.interactions.Actions.keyDown(Actions.java:85)
at org.stag.hello.HelloStepDefs.whenStep(HelloStepDefs.java:52)
at ✽.When an action takes place(hello.feature:8)


My Environment:
Firefox 8.0
Linux (Kubuntu) -- 3.0.0-13-generic #22-Ubuntu
Selenium -- 2.14.0

darrell

unread,
Nov 30, 2011, 10:42:56 AM11/30/11
to webdriver
From the error message, I would suspect it doesn't like you to use
keyDown or keyUp with the Keys.F5.

Ctrl is a modifier key but F5 is not. You probably want to use:


actionObject.keyDown(Keys.CONTROL).sendKeys(Keys.F5).keyUp(Keys.CONTROL).perform();

Darrell

On Nov 30, 9:32 am, Robert <restag...@gmail.com> wrote:
> Krishnan,
>
> When I attempt to use the example code, I get the following...what does
> this mean?
>
> java.lang.IllegalArgumentException: Key Down / Up events only make sense
> for modifier keys.
> at

> org.openqa.selenium.interactions.internal.SingleKeyAction.<init>(SingleKeyA ction.java:46)

Mattayi

unread,
Dec 1, 2011, 10:25:38 AM12/1/11
to webdriver
@Krishnan

I too am getting the same error message


java.lang.IllegalArgumentException: Key Down / Up events only make
sense
for modifier keys.

Krishnan Mahadevan

unread,
Dec 1, 2011, 10:30:04 AM12/1/11
to webd...@googlegroups.com
Mathew,
Did you try using Darrell's recommendation ?

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"


Mattayi

unread,
Dec 5, 2011, 5:54:01 AM12/5/11
to webdriver
yeah it worked.
Thanks

On Dec 1, 8:30 pm, Krishnan Mahadevan

sba...@2u.com

unread,
Jun 24, 2013, 3:02:49 AM6/24/13
to webd...@googlegroups.com
Hello Everyone,

I need to open print dialogue using selenium webdriver. How can I perform Cntrl + P functionality. There is no link which opens print dialogue

Somesh

darrell

unread,
Jun 24, 2013, 10:05:30 AM6/24/13
to webd...@googlegroups.com
Somesh,

If you have a new topic you should open a new thread. Tacking your question onto the end of thread which is over a month old could cause people to miss your question.

That said, WebDriver allows you to do web browsing. Printing is a system level action. WebDriver does not go outside the web browser window. Even if you could open a print dialogue, WebDriver would halt and wait for something else to close the print dialogue. If you need to test printing then you want to look outside of WebDriver.

Darrell

SUBBARAO GADDAM

unread,
Jun 24, 2013, 3:22:59 AM6/24/13
to webd...@googlegroups.com
use this code:

Actions builder =new Actions(driver);
builder.sendKeys(Keys.chord(Keys.CONTROL,"P")).perform();


--
You received this message because you are subscribed to the Google Groups "webdriver" group.
To unsubscribe from this group and stop receiving emails from it, send an email to webdriver+...@googlegroups.com.

To post to this group, send email to webd...@googlegroups.com.
Visit this group at http://groups.google.com/group/webdriver.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages