Skip to content
This repository has been archived by the owner on Nov 29, 2018. It is now read-only.

[SafariDriver] Cannot navigate forwards or backwards in browser history. #3771

Open
lukeis opened this issue Mar 3, 2016 · 15 comments
Open

Comments

@lukeis
Copy link
Member

lukeis commented Mar 3, 2016

Originally reported on Google Code with ID 3771

When navigating forwards or backwards in browser history, the injected script's SafariContentWebPage
object will lose its SafariContentBrowserTabProxy reference (!!safari.self.tab ===
false).  Consequently, the page and extension lose the ability to communicate with
each other.  For the user, this manifests as the SafariDriver hanging.

Currently, the history navigation commands are disabled in the SafariDriver, letting
the user know this is a known issue.

Reported by jmleyba on 2012-04-22 00:04:59

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Does this issue happens even if we navigate from Page 1 to Page 2 and again Page1 using
the links provided in application to do the navigation.?
Please provide inputs.

Reported by shubh.goyal on 2012-08-17 14:02:55

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Yes, this applies to that as well.

Reported by jmleyba on 2012-08-17 14:48:43

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Regarding comment 1 & 2, are we referring to javascript-based links that call the browsers
back and forward functionality? 

Or are we talking about standard hyperlinks (regular valid URLs, no browser history
dependency) not working when you click a link that goes back to a previously visited
page? E.g. table of contents w/ previous/next links hard coded to specific page (or
at least dynamically generated on server side before returned to browser as HTML).

Just asking for clarification, since novice users might be confused with the question
 in comment 1 and response in comment 2, since the question wasn't phrased crystal
clear.

Reported by mangaroo on 2012-08-17 18:09:15

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

If you move forwards or backwards in the browser history, the SafariDriver will stop
working (e.g. history.back()).  Clicking on a link that points at a previously visited
page does not move you back in history, it counts as a new page load and will work.

Reported by jmleyba on 2012-08-17 19:14:11

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Thanks. Any thoughts on a solution to this issue? 

Except for memory usage issues, and more complexity, what if SafariDriver managed the
session's history itself than relying on the browser? Though that would mean we're
not testing Safari's history navigation implementation, but at least will be a workaround
for users to not have to change their code or add special conditions/exceptions for
Safari for back/forward navigation.

E.g. SafariDriver could have it's own data structure (linked list and pointers, etc.)
to store page history for navigating back & forth, and traverse the data structure
when the WebDriver back/forward navigation commands are called, keeping note of current
page location within history structure, instead of calling Safari browser's native
implementation.

Reported by mangaroo on 2012-08-17 22:43:04

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

As noted in the initial report, the problem is the way Safari reloads an old page. 
It doesn't fully initialize the extension for the page, breaking the SafariDriver's
communication mechanism in the process.

Reported by jmleyba on 2012-08-18 02:21:44

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Thanks for clarification on comment 3.
The Qus in comment 1 is w.r.t the standard hyperlinks which points to the previousely
visited page. As per my understading this issue is not applicable for the above case
as clicking the link loads the again.

Thanks for clarification.

Reported by kapil.goyal99 on 2012-08-19 13:42:16

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

I am using the following code as a workaround and did not notice any side effects so
far. 

(SeleniumSession.Driver as IJavaScriptExecutor).ExecuteScript("history.go(-1)");

Hope this helps.

Reported by tsurankoul on 2013-02-07 23:04:28

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

What version of Safari?  I haven't checked this functionality since I filed the bug.

Reported by jmleyba on 2013-02-08 02:02:44

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

I'm seeing this bug. I'm using webdriver via Protractor https://github.com/angular/protractor

It's throwing this message when trying to issue the navigate/back command:
"Yikes! Safari history navigation does not work..." 
https://code.google.com/p/selenium/source/browse/javascript/safari-driver/inject/commands.js?spec=svnc31aea4cb6e9c8f6d75fa8533c990aba55f2d407&r=c31aea4cb6e9c8f6d75fa8533c990aba55f2d407#71

My seleniumServerJar = './selenium/selenium-server-standalone-2.35.0.jar'

Reported by jeffreyfroom on 2013-10-30 20:30:31

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

This is still happening. Tested Dec 2 2014

Reported by matthhar12 on 2014-12-02 12:00:12

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Still issue in 2.44.0

Reported by normandiggs on 2014-12-30 18:57:04

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

No need to post comments about this still being present. This bug documents a known
issue that can't be fixed because of how Safari extensions work. If/when this gets
fixed, the bug will be closed.

Reported by jmleyba on 2014-12-30 18:59:10

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

As written by tsurank...

(SeleniumSession.Driver as IJavaScriptExecutor).ExecuteScript("history.go(-1)");

it worked for me flawlessely

Reported by paramjit2k on 2015-06-29 12:10:13

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Reported by luke.semerau on 2015-09-17 17:44:49

  • Labels added: Restrict-AddIssueComment-Commit

@SeleniumHQ SeleniumHQ locked and limited conversation to collaborators Mar 4, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant