Search code examples
javaandroidjsonwebdriver

Android WebDriver. XMLHttpRequest cannot load 'URL'. Origin 'URL' is not allowed by Access- Control-Allow-Origin. at null:1


I am running my automated tests on Nexus 10 (Android 4.2) using Selenium WebDriver and Java. The error I face with is:

XMLHttpRequest cannot load 'URL1'. Origin 'URL2' is not allowed by Access- Control-Allow-Origin. at null:1
  • URL1 - back-end which is based on json;
  • URL2 - front-end.

This error doesn't occur for FireFox, Chrome, IE 10. But it always occur for WebDriver on Android. Due to it Log in to the system is unavailable. WebDriver is able to click, sendKeys and etc.

So the question is: Is any workaround exists to avoid this issue? May be some settings which I should change for WebDriver? May be someone faced with something like this before. I appreciate any suggestions.

I've tried apk 2.21.0 and 2.32.0.


Solution

  • In my case, that was the problem with web sockets. The application is based on web sockets. The point is - Native android browser doesn't support sockets until Android 4.4 and Selenium use exactly native android browser to execute tests.

    I've tested the same at emulator with Android 4.4 and everything works fine. Thanks everyone for help.