SeleniumHQ / selenium-google-code-issue-archive

Archive, please see main selenium repo
https://github.com/seleniumhq/selenium
346 stars 194 forks source link

UnhandledWebDriverError: Permission denied for <http://www.facebook.com> to get property Window.frameElement - SEE COMMENTS 47, 55 AND 64 FOR WORKAROUND #2863

Closed lukeis closed 8 years ago

lukeis commented 8 years ago

Originally reported on Google Code with ID 2863

I'm sending a message to select an iframe (http://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/frame)
to selenium via the facebook php bindings / RemoteWebDriver, but instead of selecting
the frame I'm getting an exception:

08:38:00.730 WARN - Exception thrown
org.openqa.selenium.WebDriverException: Permission denied for <http://www.facebook.com>
to get property Window.frameElement; duration or timeout: 15.04 seconds
Build info: version: '2.12.0', revision: '14666', time: '2011-11-10 18:35:23'
System info: os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version:
'1.6.0_29'
Driver info: driver.version: RemoteWebDriver

    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)

    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)

    at java.lang.reflect.Constructor.newInstance(Unknown Source)

    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:147)

    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:113)

    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:416)

    at org.openqa.selenium.remote.RemoteWebDriver$RemoteTargetLocator.frame(RemoteWebDriver.java:636)

    at org.openqa.selenium.support.events.EventFiringWebDriver$EventFiringTargetLocator.frame(EventFiringWebDriver.java:561)

    at org.openqa.selenium.remote.server.handler.SwitchToFrame.call(SwitchToFrame.java:52)

    at org.openqa.selenium.remote.server.handler.SwitchToFrame.call(SwitchToFrame.java:1)

    at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)

    at java.util.concurrent.FutureTask.run(Unknown Source)

    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)

    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

    at java.lang.Thread.run(Unknown Source)

Caused by: org.openqa.selenium.remote.ErrorHandler$UnknownServerException: Permission
denied for <http://www.facebook.com> to get property Window.frameElement
Build info: version: '2.12.0', revision: '14666', time: '2011-11-10 18:35:23'
System info: os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version:
'1.6.0_29'
Driver info: driver.version: unknown

I'm using Firefox 8.  I can't tell whether this is new behavior since changing from
FF8 or Selenium 2.11 or changing to the facebook php bindings.  Sorry I can't be more
specific but a lot is in flux at the moment.  It does happen 100% of the time though.

Here's the relevant line from the selenium log:

08:37:45.693 INFO - Executing: [switch to frame: app_runner_4ec53860c57652b93621183]
at URL: /session/1321547817083/frame)

Thanks for your help.

-DB

Reported by dbyron0 on 2011-11-17 16:46:41

lukeis commented 8 years ago
I did a bit of version swapping and figured this out.  I no longer get the exception
with Firefox 7, using selenium 2.12.  So perhaps FF8 is doing something differently?
With any luck the stack trace is helpful.

Reported by dbyron0 on 2011-11-17 17:40:21

lukeis commented 8 years ago
This should be fixed by r14704 (i.e. will be part of the 2.13 release). Please reopen
if that's not the case.

Reported by jari.bakken on 2011-11-17 18:36:39

lukeis commented 8 years ago
Selenium 2.13 works with FF7, but when I upgrade to FF8 I get the same stack trace as
with 2.12.

Reported by dbyron0 on 2011-11-18 16:25:30

lukeis commented 8 years ago

Reported by jari.bakken on 2011-11-18 23:30:12

lukeis commented 8 years ago
I can confirm this happens for Firefox 8 when switching to a frame with an empty ID
provided:

driver.switchTo().frame("");

Once I added the proper ID instead of an empty string the exception was gone.

Reported by VooooD on 2011-11-19 12:00:49

lukeis commented 8 years ago

Reported by barancev on 2011-11-19 15:42:42

lukeis commented 8 years ago
As far as I can tell, the JSON I'm sending includes a non-empty ID.  I don't think curl
in php doesn't have something like CURLOPT_DEBUGFUNCTION and I haven't looked a protocol
analyzer, but I believe I'm sending:

{"id":"app_runner_4eca6feeba17f4c43088079"}

Reported by dbyron0 on 2011-11-21 15:36:48

lukeis commented 8 years ago
@VooooD  Try finding a WebElement for the frame and switching to that:

WebElement iframe = driver.findElement(By.name("my-iframe"));
driver.switchTo().frame(iframe);

@dbyron0 You could try the same, but I'm not sure if the php bindings support this.

Reported by jmleyba on 2011-11-25 03:31:27

lukeis commented 8 years ago

Reported by barancev on 2011-11-25 08:21:38

lukeis commented 8 years ago
@jmleyba

FirefoxDriver driver;
driver.get("some_page");
FirefoxDriver newDriver = (FirefoxDriver) driver.switchTo().frame("iframe_canvas");

The above code did the trick for me. Why are you trying to reference the iframe as
a WebElement?

Reported by VooooD on 2011-11-25 08:39:43

lukeis commented 8 years ago
I can't tell if the NeedsClarification status is for me or not.  I just tried this with
selenium 2.14.  I get the same exception.  The stack trace is slightly different so
here it is:

11:20:23.711 WARN - Exception thrown
org.openqa.selenium.WebDriverException: Permission denied for <http://www.facebook.com>
to get property Window.frameElement; duration or timeout: 15.11 seconds
Build info: version: '2.14.0', revision: '14955', time: '2011-11-29 11:42:43'
System info: os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version:
'1.6.0_29'
Driver info: driver.version: RemoteWebDriver

    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)

    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)

    at java.lang.reflect.Constructor.newInstance(Unknown Source)

    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:147)

    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:113)

    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:400)

    at org.openqa.selenium.remote.RemoteWebDriver$RemoteTargetLocator.frame(RemoteWebDriver.java:620)

    at org.openqa.selenium.support.events.EventFiringWebDriver$EventFiringTargetLocator.frame(EventFiringWebDriver.java:561)

    at org.openqa.selenium.remote.server.handler.SwitchToFrame.call(SwitchToFrame.java:52)

    at org.openqa.selenium.remote.server.handler.SwitchToFrame.call(SwitchToFrame.java:1)

    at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)

    at java.util.concurrent.FutureTask.run(Unknown Source)

    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)

    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

    at java.lang.Thread.run(Unknown Source)

Reported by dbyron0 on 2011-12-01 19:23:49

lukeis commented 8 years ago
Issue 3018 has been merged into this issue.

Reported by barancev on 2011-12-08 07:09:23

lukeis commented 8 years ago
Issue 2929 has been merged into this issue.

Reported by dawagner on 2011-12-08 15:25:30

lukeis commented 8 years ago
Recently merged Issue 3018 came from Issue 2921.

I was not getting the Permission Denied Facebook error using Se v2.13 & FF v8.

The fix (r15093) from Issue 2921 (which I tested independently before it was released
with 2.14) is what started consistently generating this error for me. (If this helps)

Reported by titus.fortner@tippr.com on 2011-12-08 16:26:13

lukeis commented 8 years ago
Why is this ticket in the NeedsClarification state? I am seeing this consistently as
well and if you let us know what other information you need, we can provide it. This
has become a big issue for us because we had to update firefox to the latest version
and now most of our tests do not work.

Reported by mariofduarte on 2011-12-12 09:59:29

lukeis commented 8 years ago
Is there a workaround to this problem for who has to use FF8?

Reported by slider3 on 2011-12-12 22:06:26

lukeis commented 8 years ago
Setting capability.policy.default.Window.frameElement to "allAccess" in FF profile might
help. It does not answer the question WHY it started to be like that.

Reported by nebehr.gudahtt on 2011-12-13 13:18:40

lukeis commented 8 years ago
we have several tests within facebook which started failing with this change as well.
used to work in older 2.x builds as other have mentioned.

Reported by jubishop on 2011-12-13 21:02:11

lukeis commented 8 years ago
Seeing this consistently on ff8 Windows with Selenium 2.15

Reported by pettazz on 2011-12-13 23:46:00

lukeis commented 8 years ago
I've the same problem, however, the event is different in my case.

WebElement element = WaitForObjectToLoadAndReturnIfExist (strXpath,intSyncTimeOut);
...
...
element.click();

I guess the problem is same.

With Selenium 2.15 and FF 8.0.1

Reported by nilanjan.gm on 2011-12-15 11:30:29

lukeis commented 8 years ago
I get something very similar, but not for facebook.

'Error: Permission denied for <http://localhost:3001> to get property HTMLDocument.compatMode'
when calling method: [wdIMouse::move] (Selenium::WebDriver::Error::UnknownError)

The page is very JS heavy, and uses iframes to handle async uploads.  Basically any
attempt to click anything on the page fails with this error.  Let me know if I can
try anything, this is quite an important part of our site to have automated tests for.

Reported by patrick@redbubble.com on 2011-12-22 03:31:07

lukeis commented 8 years ago
@VooooD - the code that jmleyba provided was the only code that worked for me via the
C# WebDriver (2.15) w/ Firefox 8.0. I think it may have something to do with the order
by which certain operations are completed in the different methods (and perhaps this
isn't an issue for all drivers or works differently for other drivers) such that the
underlying code that finds the iframe, when the iframe is provided by name, is not
equivalent to driver.findElement(By.name("my-iframe"));

Reported by s4Logic on 2011-12-23 23:36:29

lukeis commented 8 years ago
Seeing the same problem with FF9 and FF8 (works fine with FF7)
WebDriver: 2.17.0

This error occurred on clicking <a> link.

======================================================================================================================================
org.openqa.selenium.WebDriverException: Permission denied for <http://reviews.crateandbarrel.com>
to get property HTMLDocument.compatMode
Command duration or timeout: 29 milliseconds
Build info: version: '2.17.0', revision: '15540', time: '2012-01-16 16:52:31'
System info: os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version:
'1.6.0_27'
Driver info: driver.version: RemoteWebDriver
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.6.0_27]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
~[na:1.6.0_27]
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
~[na:1.6.0_27]
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513) ~[na:1.6.0_27]
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:147)
~[selenium-java-2.17.0.jar:na]
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:113)
~[selenium-java-2.17.0.jar:na]
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:439) ~[selenium-java-2.17.0.jar:na]
    at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:231)
~[selenium-java-2.17.0.jar:na]
    at org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:72) ~[selenium-java-2.17.0.jar:na]
======================================================================================================================================

Reported by mgoodnow80 on 2012-01-17 17:44:08

lukeis commented 8 years ago
We also have tests which used to work now failing. Here is a simple example (we are
using capybara with selenium-webdriver 2.17.0).

visit 'http://www.facebook.com/scentiments?sk=app_135381266534298'
click 'Scentury Club'
wait 3
within_frame(find('#pagelet_app_runner iframe')['name']) do
  page.should have_content "Scentury Club"
end

And here is the error:

     Failure/Error: within_frame(find('#pagelet_app_runner iframe')['name']) do
     Selenium::WebDriver::Error::UnknownError:
       Permission denied for <http://www.facebook.com> to get property Window.frameElement

It appears that driver.switch_to.frame call is failing.

Reported by rtekiela on 2012-01-20 00:12:23

lukeis commented 8 years ago
also seeing this issue when using chrome, but with much less frequency than with firefox

Reported by danc@zoosk.com on 2012-01-31 17:39:37

lukeis commented 8 years ago
This is probably caused by the page in question setting document.domain - I've seen
this problem several times on a page of ourse (see r15428, r15123), but have so far
been unable to reduce it. How to reproduce it is apparently covered in a Mozilla bug
report that is not open to the public.

The solution in the cases I've seen has always been to modify the FirefoxDriver to
not unwrap elements uneccessarily. 

Reported by jari.bakken on 2012-02-08 13:52:31

lukeis commented 8 years ago
The security flags have been removed since fixes for this have landed in Mozilla Central.

https://bugzilla.mozilla.org/show_bug.cgi?id=674182
https://bugzilla.mozilla.org/show_bug.cgi?id=653926

The issues in these bugs were around loadscript and compartments. if anything it *could*
be related to bug 674182

The main issue is we need to go through the code and have a look at anywhere and everywhere
we unwrap/wrap elements and then see if it is really needed.

Reported by david.burns@theautomatedtester.co.uk on 2012-02-08 14:20:12

lukeis commented 8 years ago
Getting same issue on FF8. david, Can you provide more insight on unwrap/wrap elements
and how to do that?

Reported by thavvarao on 2012-02-10 10:54:33

lukeis commented 8 years ago
We are using FF9.0.1, FF10 and WebDriver 2.15.0. Getting below error

caused by: org.openqa.selenium.remote.ErrorHandler$UnknownServerException: 'Error:
Permission denied for <URL> to get property HTMLDocument.compatMode' when calling method:
[wdIMouse::move]
Build info: version: '2.15.0', revision: '15105', time: '2011-12-08 09:56:25'
System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1', java.version:
'1.7.0_02'
Driver info: driver.version: unknown

Reported by thavvarao on 2012-02-11 08:03:20

lukeis commented 8 years ago
We need to up the priority on this bug!
It's a major blocker us from upgrading FF testing on anything newer then FF7.

It's very easily reproducible. Please describe what you need us to do so we can help
solve this problem.

Thanks,
-Mike

Reported by mgoodnow80 on 2012-02-21 22:10:07

lukeis commented 8 years ago
yep Facebook remains stuck on FF7 thanks to this bug.  Severely slowing our WebDriver
adoption.

Reported by jubishop on 2012-02-21 22:17:23

lukeis commented 8 years ago
It used to be a blocking issue for us too.

Finally, we found the following workaround:
- We have recognized that this error occurs when we call the selenium.open on a page
that has facebook integration
- We have found that: if we catch the exception and re-open the same url, it's working
fine
- So, we've overriden the selenium.open method like this:
    @Override
    public void open(String url) {
        try {
            super.open(url);
        } catch (SeleniumException e) {
            logger.logWarning("Error while opening url: " + url + ". [Error message:
" + e.getMessage() + "]");
            logger.logWarning("This is a known Selenium issue, see details: 'http://code.google.com/p/selenium/issues/detail?id=2863'.");
            logger.logWarning("Workaround: Try to reopen the url!");
            super.open(url);
        }
    }

- We have been using this workaround for more than one week (Selenium 2.19 with old
Selenium API and FF10) and it seems to be working fine, the issue has disappeared.

Reported by Robert.Ambrus.2 on 2012-02-22 07:57:47

lukeis commented 8 years ago
other solution you can find here..http://aboutselenium.blogspot.in/2012/02/handling-permission-denied-error-for.html

Reported by thavvarao on 2012-02-23 16:56:10

lukeis commented 8 years ago
Comment 15 by mariofdu...@gmail.com, Dec 12, 2011

Why is this ticket in the NeedsClarification state? I am seeing this consistently as
well and if you let us know what other information you need, we can provide it. This
has become a big issue for us because we had to update firefox to the latest version
and now most of our tests do not work.

+1

Reported by Dimissor on 2012-03-02 16:10:00

lukeis commented 8 years ago
I am having trouble with this issue as well. Here is a link to a gist to help replicate
it:  https://gist.github.com/gists/1997066/

If someone tries to run the script and replaces $email and $password with a valid Facebook
email and password, then it should it the error "Permission denied for <http://www.facebook.com>
to get property Window.frameElement;" when we try to access the frame.

Reported by amccosham@coupsmart.com on 2012-03-08 21:40:00

lukeis commented 8 years ago
The issue is still actual

Reported by lykvymolly on 2012-03-20 18:58:56

lukeis commented 8 years ago
I'm also running into the same issue pretty consistently (Firefox 10.0.2, rest of the
details below):

17:38:33.172 WARN - Exception thrownorg.openqa.selenium.WebDriverException: Permission
denied for <http://www.facebook.com> to get property Window.frameElement
Command duration or timeout: 60.08 seconds
Build info: version: '2.20.0', revision: '16008', time: '2012-02-27 19:03:04'
System info: os.name: 'Mac OS X', os.arch: 'amd64', os.version: '10.7.3', java.version:
'1.7.0_04-ea'
Driver info: driver.version: RemoteWebDriver
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
        at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:170)
        at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:123)
        at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:438)
        at org.openqa.selenium.remote.RemoteWebDriver$RemoteTargetLocator.frame(RemoteWebDriver.java:669)
        at org.openqa.selenium.support.events.EventFiringWebDriver$EventFiringTargetLocator.frame(EventFiringWebDriver.java:569)
        at org.openqa.selenium.remote.server.handler.SwitchToFrame.call(SwitchToFrame.java:52)
        at org.openqa.selenium.remote.server.handler.SwitchToFrame.call(SwitchToFrame.java:1)
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
        at java.util.concurrent.FutureTask.run(FutureTask.java:166)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
        at java.lang.Thread.run(Thread.java:722)
Caused by: org.openqa.selenium.remote.ErrorHandler$UnknownServerException: Permission
denied for <http://www.facebook.com> to get property Window.frameElement
Build info: version: '2.20.0', revision: '16008', time: '2012-02-27 19:03:04'
System info: os.name: 'Mac OS X', os.arch: 'amd64', os.version: '10.7.3', java.version:
'1.7.0_04-ea'Driver info: driver.version: unknown
17:38:33.181 WARN - Exception: Permission denied for <http://www.facebook.com> to get
property Window.frameElement
Build info: version: '2.20.0', revision: '16008', time: '2012-02-27 19:03:04'
System info: os.name: 'Mac OS X', os.arch: 'amd64', os.version: '10.7.3', java.version:
'1.7.0_04-ea'
Driver info: driver.version: unknown

Reported by n@daaku.org on 2012-04-06 00:46:12

lukeis commented 8 years ago
I've had this problem for quite a while. Currently running Firefox 11, Selenium Server
2.20.0, Python 2.7.

After much digging on the internet, I've discovered a few "workarounds". I put that
in quotes because some of them are hardly workarounds. Some of them are even hackish
and make me feel all dirty inside. Anyways, here they are:

1. Proxy Injection Mode (least effective)
By adding the flag -proxyInjectionMode to the Selenium Server start up command, and
setting your browser to one of *pifirefox, *chrome, or *iehta.

This solution works only sometimes. Many times I have to play around with the combination
of the these flags to run a test. For me at least, it has proven unreliable as a long
term solution.

2. Allow www.facebook.com access to those properties
This one here is the hackish one that makes me feel all dirty. You can create rules
in the prefs.js file in your firefox profile to allow www.facebook.com access to those
properties. I highly suggest against using this solution as it is essentially poking
holes in your browsers security layer. However, if you've really tried everything else
(and I mean everything), including Solution #3 down there, then I supposed I can't
stop you from trying this one out.

In /path-to-firefox-profiles-directory/profile-name/prefs.js (C:\Documents and Settings\<username>\Application
Data\Mozilla\Profiles\ on Windows XP) I've appended the following lines:

# Allow Facebook access to XSS
# First Create policy group
user_pref("capability.policy.policynames", "trustable");
# Add offending domain to policy group
user_pref("capability.policy.trustable.sites", "http://www.facebook.com");
# Allow policy group access to these properties
user_pref("capability.policy.trustable.Location.href", "allAccess");
user_pref("capability.policy.trustable.HTMLDocument.readyState", "allAccess");

If you have additional properties that are denying access, simply copy the last line
and replace HTMLDocument.readyState with the property you need to allow. I used these
two properties because I was running into those ones as problems in my automation.
If you are not having problems with those, I would highly recommend removing them and
custom building your prefs.js lines for your needs.

This solution has proven to work for the cases defined 100% of the time in the semi-limited
time I've tested it (around 2 weeks). However, this is definitely not ideal as you
would have to make this change to every test machine, for every offending domain, and
for every property that is violated. The other obvious drawback is that this only applies
the fix to Firefox. If you're encountering this issue in IE, or other browsers, I do
not have a solution for those. I am currently unaware if there are any similar solutions
in other browsers.

3. Small patch in Selenium client library
This one is the most ideal out of the three solutions I've discovered. However, I'm
sure it is not fool proof, nor a robust solution to say the least. In the do_command
method, I've added a passing exception for any response that starts with "Permission
denied for".

(Examples in Python using Selenium Client library 2.20.0)
Before:
216  if (not data.startswith('OK')):
217      raise Exception, data
218  return data

After:
216  if (data.startswith('Permission denied for')):
217      print "Encountered JS error; proceeding anyways."
218  elif (not data.startswith('OK')):
219      raise Exception, data
220  return data

This has also proven reliable in my testing (around 1 week) and is much less hackish
than Solution #2. However, it still has an air of hackishness and is certainly not
a long term solution. Maybe the most inconvenient part of this is that if you update
your Selenium client library, you have to re-apply this custom and very unofficial
patch.

I hope my research and experimentation proves helpful to someone. Hopefully the pain
I've gone through reaps rewards further reaching than just my code base.

- Tim Harrison
SQA² www.sqasquared.com

Reported by timlamirada on 2012-04-11 17:00:08

lukeis commented 8 years ago
Tim - Thanks for the very good and detailed write up.
I have used something similar to option 3 in my case.  It's not ideal as you say but
it does "bypass" this exception.
Hoping the WebDriver team can use this information to provide a solid fix. This bug
has been one of the major blockers preventing a lot of people from upgrading beyond
FF7.

Reported by mgoodnow80 on 2012-04-14 12:00:09

lukeis commented 8 years ago
The reason this issue is still marked NeedsClarification is that we have absolutely
no way of actually reproducing the bug.

rtekiela supplied one but unfortunately facebook has changed since, and it no longer
shows the problem.

amccosham@coupsmart.com supplied a page, but it was incomplete; it didn't include any
of the javascript for the example page.

Every other example *hasn't* included a URL, or page, being tested against, so we can't
use them to reproduce the problem; it appears to only affect pages with iframes which
point to certain sites.

If someone could supply a simple selenium script which either:
* includes a live URL which it's testing against, or
* includes a *complete* page, including HTML, javascript, CSS, which we can put on
a static web server and see the problem with
and shows the problem, we can try to fix this problem.

davehunt: You said you may have an example using paypal? If so, could you share it?

Reported by dawagner on 2012-04-14 13:06:51

lukeis commented 8 years ago
Hi 
iam using selenium-server-standalone-2.20.jar , but the api iam using is DefaultSelenium
class Api, my application involves testing with Twitter, iam getting following error
Permission denied for <https://twitter.com> to get property Location.href
com.thoughtworks.selenium.HttpCommandProcessor.throwAssertionFailureExceptionOrError(HttpCommandProcessor.java:97)
at com.thoughtworks.selenium.HttpCommandProcessor.doCommand(HttpCommandProcessor.java:91)
at com.thoughtworks.selenium.DefaultSelenium.open(DefaultSelenium.java:335)

is there any work around which works with DefaultSelenium Api 
Tim can you be more clear in explanation for small patch in selenium-client libary(senario
3)

Reported by praneeth.krishna on 2012-04-16 11:42:54

lukeis commented 8 years ago
@mgoodno...@gmail.com: You're very welcome. This has also been a huge issue for me and
my organization. Please see below for a small addition to my example which may help
you further.

@dawagner@gmail.com: I'll see if I can create a reproducible test which demonstrates
this error. First attempts at a basic Selenium IDE test have strangely proven unsuccessful.
I'll keep at it.

Since I made the post the other day, I've discovered that the command that triggers
the JavaScript error actually doesn't get executed. That being true, we need to retry
the command. In order to ensure that the command you sent was actually executed, you
have to call the do_command method from itself. Below is the modified, unofficial patch:

(Example in Python using Selenium client library 2.20.0)
Before:
216  if (not data.startswith('OK')):
217      raise Exception, data
218  return data

After:
216  if (data.startswith('Permission denied for')):
217      print "[JavaScript Error] Message: '%s' Retrying command." % data
218      self.do_command(verb, args)
219  elif (not data.startswith('OK')):
220      raise Exception, data
221  return data

@praneeth...@gmail.com: This patch applies to the library you interface with to run
methods like sel.click, sel.wait_for_page_to_load, sel.type, etc. If you want to apply
this same change, you need to locate the do_command method within that library which
should be near the top, just below the documentation.

Explanation of this patch:
When you get a response from your remote Selenium Server, your local client library
reads the beginning of the response. If it starts with the text "OK", it indicates
that the command you sent to the selenium server was successful and continues on with
your test. If it encounters anything else, it raises an exception passing the data
of the error so that a language appropriate exception can be thrown. What I've done
is right before it checks for "OK" is inserted an interception of the check. My patch
checks if the response from the Selenium Server starts with the text "Permission denied
for". If this is encountered, it prints "[JavaScript Error] Message: '<message text>'
Retrying command." then retries the command until successful.

I've added some debug statements in the library to show the format of the request and
returning data. In this example, I am logging into my client's website. You will also
see upon arriving at the member area after log in, it tries to run 'waitForPageToLoad',
it receives the permission error and retries the command. Once it receives 'OK' from
that request, it continues on to verify a <div> with my username is present on the
page.

Here is the output:

Request:  open, [u'http://www.example.com:80', 'true']
Response: u'OK'
Request:  waitForPageToLoad, [60000]
Response: u'OK'
Request:  windowMaximize, []
Response: u'OK'
Request:  getEval, ['window.moveTo(1,0)']
Response: u'OK,null'
Request:  click, ["//div[@id='banner']//a[text()='Sign In']"]
Response: u'OK'
Request:  waitForPageToLoad, [60000]
Response: u'OK'
Request:  type, ["//input[@name='login']", 'tharrison@******.com']
Response: u'OK'
Request:  type, ["//input[@name='password']", '********']
Response: u'OK'
Request:  click, ["//input[@value='Sign In']"]
Response: u'OK'
Request:  waitForPageToLoad, [60000]
Response: u'Permission denied for <https://www.facebook.com> to get property Location.href'
[JavaScript Error] Message: 'Permission denied for <https://www.facebook.com> to get
property Location.href' Retrying command.
Request:  waitForPageToLoad, [60000]
Response: u'OK'
Request:  isElementPresent, ["//div[@class='username' and text()='tharrison']"]
Response: u'OK,true'

Reported by timlamirada on 2012-04-16 19:22:10

lukeis commented 8 years ago
 timlamir...@gmail.com 
 In my case its happening when i open the twitter url, ihave extracted the selenium-standalone-2.20.jar
file, there are all class files iam unable to locate the source file, can you please
tell me name of the source file to modify and where can i find the source file to modified
as patch and as my test uses DefaultSelenium class(selenium1).

Reported by praneeth.krishna on 2012-04-17 06:34:08

lukeis commented 8 years ago
I'm facing same problem with 2.20.0 with FF 8.0.1

While trying to switch the control to iframe this problem occurring.

org.openqa.selenium.WebDriverException: Permission denied for <http://www.xxxxxxxxxxxxx.com>
to get property Window.frameElement
Command duration or timeout: 50.09 seconds
Build info: version: '2.20.0', revision: '16008', time: '2012-02-27 19:03:04'
System info: os.name: 'Windows Vista', os.arch: 'amd64', os.version: '6.1', java.version:
'1.6.0_10'
Driver info: driver.version: RemoteWebDriver
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:170)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:123)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:438)
    at org.openqa.selenium.remote.RemoteWebDriver$RemoteTargetLocator.frame(RemoteWebDriver.java:669)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: org.openqa.selenium.remote.ErrorHandler$UnknownServerException: Permission
denied for <http://www.xxxxxxxxxxxxxxxxx.com> to get property Window.frameElement
Build info: version: '2.20.0', revision: '16008', time: '2012-02-27 19:03:04'
System info: os.name: 'Windows Vista', os.arch: 'amd64', os.version: '6.1', java.version:
'1.6.0_10'
Driver info: driver.version: unknown

Reported by santoshsarma.jv on 2012-04-18 07:29:37

lukeis commented 8 years ago
We get that this is a problem.  We don't need more comments saying "I have this problem"
- unless you have a test case to add, please don't bother commenting!

Note: This seems to have happened in Firefox 8; if you use Firefox 7, you probably
won't see the problem.

Reported by dawagner on 2012-04-18 08:34:07

lukeis commented 8 years ago
Here is a simple reproducible testcase in Python: https://gist.github.com/2413653

Reported by dave.hunt on 2012-04-18 13:46:16

lukeis commented 8 years ago
This is a problem introduced by Firefox 8's cross-origin frame lock-down.  Unfortunately,
without some changes to Firefox, it's unlikely we will be able to fix this bug.

In the mean time, you can work around it by setting the following settings in a FirefoxProfile:

capability.policy.default.Window.QueryInterface='allAccess'
capability.policy.default.Window.frameElement.get='allAccess'

Note that doing so will disable all cross-origin checks in the browser, so your tests
will no longer be able to verify that there are no cross-origin javascript requests,
which are blocked by the browser.  Accordingly, we will not be making this behaviour
the default for selenium.

Reported by dawagner on 2012-05-02 13:54:08

lukeis commented 8 years ago
As a note:  even after the two capability updates you might still recieve errors about
permission denied.  If so given an error of "Permission denied for URL to get property
X.Y follow the following syntax

capability.policy.default.X.Y.get='allAccess'

to enable that capability and work around each permission as you get them.  Sort of
a game of whack-a-mole, but you will find the answer.

Reported by llaskin on 2012-05-02 14:26:32

lukeis commented 8 years ago
Issue 3217 has been merged into this issue.

Reported by barancev on 2012-05-05 14:28:57

lukeis commented 8 years ago
Great guys . 

I used to get "Permission denied " error while switching to iframe . I am using selenum
2.12 and FF 12. 

Now I just followed the workaround here. 

FirefoxProfile profile = new FirefoxProfile(); profile.setPreference("capability.policy.default.Window.QueryInterface",
"allAccess");        profile.setPreference("capability.policy.default.Window.frameElement.get",
"allAccess");

It is working great ..!! 

thanks thanks thanks :)

Reported by vamshikurra on 2012-05-15 06:52:27