How can I simulate a back button keypress?

Asked by Craig

There is currently no function to call for this and I thought that using simulate_keys would cover it, but there is no keycode in selenium/webdriver/common/keys.py for back. alt+left would do it, but simulate_keys seems to only take a single key.

Perhaps I'm missing something though - Is there a way to simulate the back button?

Question information

Language:
English Edit question
Status:
Solved
For:
selenium-simple-test Edit question
Assignee:
No assignee Edit question
Solved by:
Craig
Solved:
Last query:
Last reply:
Revision history for this message
Craig (craigtlandry) said :
#1

I've just found a solution although it is probably not ideal:

In my script I just import sst.actions.browser and then call browser.back() when needed. My guess is that the preferred way to do this would be to wrap the browser.back() in a function from sst.actions. Still though, this covers my needs for now. Marking is solved.

Revision history for this message
Corey Goldberg (coreygoldberg) said :
#2

Craig,

yup, that's how I'd approach it..

> My guess is that the preferred way to do this
> would be to wrap the browser.back() in a
> function from sst.actions

something like a `go_back()` function would fit with the API/approach.

feel free to enter a bug to ask for this enhancement (I'll add it), or submit a merge proposal if you want to help with dev.

regards,

-Corey

Revision history for this message
Craig (craigtlandry) said :
#3

go_back() sounds good to me. When I get a few minutes I'll open a
feature request and submit a patch with it.

On Mon, Jan 23, 2012 at 2:05 PM, Corey Goldberg
<email address hidden> wrote:
> Your question #185576 on selenium-simple-test changed:
> https://answers.launchpad.net/selenium-simple-test/+question/185576
>
> Corey Goldberg posted a new comment:
> Craig,
>
> yup, that's how I'd approach it..
>
>> My guess is that the preferred way to do this
>> would be to wrap the browser.back() in a
>> function from sst.actions
>
> something like a `go_back()` function would fit with the API/approach.
>
> feel free to enter a bug to ask for this enhancement (I'll add it), or
> submit a merge proposal if you want to help with dev.
>
> regards,
>
> -Corey
>
> --
> You received this question notification because you asked the question.

Revision history for this message
Corey Goldberg (coreygoldberg) said :
#4

I just added the "go_back()" function. It is available in trunk.