xebia / Xebium

Xebium provides Selenium (webdriver) bindings for FitNesse, with Selenium-IDE support
http://xebia.github.com/Xebium/
Apache License 2.0
76 stars 62 forks source link

Xebium is incompatible with ios-driver against a native app #145

Open sglebs opened 9 years ago

sglebs commented 9 years ago

When trying to use Xebium with the ios-driver http://ios-driver.github.io/ios-driver/?page=home I noticed that it does not work. Using a proxy tool (Charles Proxy) I noticed that Xebium is making requests that ask the WebDriver to evaluate JavaScript code, as if it were a brrowser app. When running the same test from Python against the WebDriver, no such thing happens.

Here in Python:

from selenium import webdriver
cap = {
'device' : 'iphone',
'language': 'en',
'locale': 'en_US',
'CFBundleName': 'InternationalMountains',
'simulator':True,
'variation':'iPhone5s'
}
driver = webdriver.Remote("http://localhost:5555/wd/hub", cap)
cellByName = driver.find_element_by_name ("Mountain 1")
print (cellByName)
cellByName.click()

Here's the wire (all works fine):

POST /wd/hub/session/9dee5f9f-e373-4b5a-bef1-e2cce2fe5bc7/element HTTP/1.1
Accept-Encoding: identity
Content-Length: 93
Host: 127.0.0.1:5555
Accept: application/json
User-Agent: Python-urllib/2.7
Connection: close
Content-Type: application/json;charset=UTF-8

{"using": "name", "sessionId": "9dee5f9f-e373-4b5a-bef1-e2cce2fe5bc7", "value": "Mountain 1"}

HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Connection: close
Server: Jetty(8.y.z-SNAPSHOT)

{"state":null,"sessionId":"9dee5f9f-e373-4b5a-bef1-e2cce2fe5bc7","hCode":887467035,"value":{"ELEMENT":"4","type":"UIATableCell"},"class":"org.openqa.selenium.remote.Response","status":0}

POST /wd/hub/session/9dee5f9f-e373-4b5a-bef1-e2cce2fe5bc7/element/4/click HTTP/1.1
Accept-Encoding: identity
Content-Length: 64
Host: 127.0.0.1:5555
Accept: application/json
User-Agent: Python-urllib/2.7
Connection: close
Content-Type: application/json;charset=UTF-8

{"sessionId": "9dee5f9f-e373-4b5a-bef1-e2cce2fe5bc7", "id": "4"}

HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Connection: close
Server: Jetty(8.y.z-SNAPSHOT)

{"state":null,"sessionId":"9dee5f9f-e373-4b5a-bef1-e2cce2fe5bc7","hCode":602051175,"value":"","class":"org.openqa.selenium.remote.Response","status":0}

And here it is from FitNesse:

| script |
|start browser |{"remote": "${url}", "device" : "iphone", "language": "en", "locale": "en_US", "CFBundleName": "InternationalMountains", "simulator": "true", "variation":"iPhone5s", "instruments": "true"} |on url    |http://www.apple.com|
| ensure | do | click | on | name=Mountain 1 |
|stop browser |

And this is the wire:

POST /wd/hub/session/241e691b-522a-4e3d-aa7b-0ccd586b742e/execute HTTP/1.1
Content-Type: application/json; charset=utf-8
Content-Length: 74005
Host: localhost:5555
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.3.6 (java 1.5)
Accept-Encoding: gzip,deflate

{"script":"return (function() { return (function(){return function(){var k,l\u003dthis;function n(a){return void 0!\u003d\u003da}\nfunction aa(a){var b\u003dtypeof a;if(\"object\"\u003d\u003db)if(a){if(a instanceof Array)return\"array\";if(a instanceof Object)return b;var c\u003dObject.prototype.toString.call(a);if(\"[object Window]\"\u003d\u003dc)return\"object\";if(\"[object Array]\"\u003d\u003dc||\"number\"\u003d\u003dtypeof a.length\u0026\u0026\"undefined\"!\u003dtypeof
...
[stuff deleted - it was a gigantic script]
...
\nfor(var Xd;Vd.length\u0026\u0026(Xd\u003dVd.shift());)!Vd.length\u0026\u0026n(Ud)?Wd[Xd]\u003dUd:Wd\u003dWd[Xd]?Wd[Xd]:Wd[Xd]\u003d{};; return this._.apply(null,arguments);}.apply({navigator:typeof window!\u003dundefined?window.navigator:null,document:typeof window!\u003dundefined?window.document:null}, arguments);}\n).apply(null, arguments);})(arguments[0]);","args":["name\u003dMountain 1"]}

HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Content-Length: 180
Server: Jetty(8.y.z-SNAPSHOT)

{"state":null,"sessionId":"241e691b-522a-4e3d-aa7b-0ccd586b742e","hCode":1252021692,"value":"Can't find variable: window","class":"org.openqa.selenium.remote.Response","status":17}

I tried to disable the fast xebium emulation, it did not fix the problem:

| use fast selenium emulation | false |

Is there a way to make Xebium work properly like when using the WebDriver? Why is it insisting in trying to execute JavaScript against the DOM? There's no DOM in a native IOS app.

raboof commented 9 years ago

I'm not sure, but could you try setting the 'useFastSeleniumEmulation' option on SeleniumDriverFixture? I'm afraid this'll only work for some commands, though.