montagejs / screening

49 stars 16 forks source link

Screening should interact with chrome apps #113

Open irinamok opened 12 years ago

irinamok commented 12 years ago

Screening should work with apps distributed as chrome extensions (like Ninja)

irinamok commented 12 years ago

We might be able to work with chrome apps using webdriver's driver.switchTo().window("windowName"); API. We need to figure out how to get window handle, and how to start chrome app, and how to get window handle.

eliseosoto commented 12 years ago

Some resources that might be use useful (haven't tested them myself):

--load-extension command line switch. ChromeDriver Capabilities and Switches - We need to experiment with this and see if we can pass them as the desiredCapabilties for /session

eliseosoto commented 12 years ago

There are two ways to install Chrome extensions via webdriver:

  1. Unpacked extensions Simply use the --load-extension command line switch and pass it the path to the root of the unpacked extension (not the CRX)

    POST http://localhost:9515/session

    {"desiredCapabilities":{
    "browserName":"chrome", 
    "chrome.switches": ["--load-extension=/path/to/extension/root"]
    }}
  2. Extension packed as a CRX Use chrome.extensions capability and pass it the extension as a base64 encoded string. This example will actually install a small extension.

    POST http://localhost:9515/session

    {"desiredCapabilities":{"browserName":"chrome", "chrome.extensions": ["Q3IyNAIAAACiAAAAgAAAADCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA5q4/Wo6YW00qHLT1cLRBlWwmxq+2ZjZEMpSIPPoheuvFaEOBI4nBpyK7kTYqlPtrtceMyIQaZ+95k1vryxbtmVF5S3Gbgvt0tKA21h8Eobn7ji7p7W1mCGt0ENAVpa8/XS3BV8+sjrGeGyA6hP25Y1LZIMt/yr8GASSt8r+mGEcCAwEAAROsu46wceubhWO2VPlIS/rff04CRuMl3wpIGe9eO+IuHG1OJJCz/MCxJEoh95Lt0Hg3TGGvrpA9cE+8bK0Jn3rvETNjcO355KMmtGCx5yWjFloBaleuuvHjjGQVM/HZXjdGn5RUSK8qXSRoQq/qbqvGKMkHpOaTOnKOVaim/eEpUEsDBBQAAAAIAAAAAAA7dLv19AAAAOsDAAAIAAAAaWNvbi5wbmfrDPBz5+WS4mJgYOD19HAJAtICIMzBDCQ1dPmDgRRLuqOvIwPDxn7uP4msQD5j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d0fv1zRhJiEp1dSzc+ExY2f8uJ6kXwrwriKJhysCsgFFwdRNPG8xqYOiyaZa3yuvGiyXSJYlasIZaVn/AtQSwMEFAAAAAgAAAAAAEafV5dZAQAADAIAAAgAAABwb3B1cC5qc21Qu07EMBDs8xWja5LTgQ8oeRQQrkDiURxUiCKxN4mFzwt+BCJ0/44dpKtws97RzOzsrteo+WNyuh8CKrnE2cnpGZ4HQj043um4w3UMAzsvcG0MZqKHI09uJCWK9RovnsAdwqA9PEcnCZIVIbU9j+QsKbQTGtxsb499mAzBaEk2ycLQBMjGoqXs1HG0CtomnHB/V28etxt02pAoiqKLVgbNFjKp3yta4qcAZI5JIjStF/RNMgbaSqc/QmWjMUeJkd9PDnS+UCzjjmwQLatJzFFE28j33uXBNRt2V+UCK2RD11MQWqVuUS72y4tk9aWt4i8hDXuqErIvioNlo9RmTJ977QNZclV5+/RQsw0Z40aRKo9w2KH6Sz82DkqPHlc4GH1GctOWDMnALt28KhOjnOd37FBljU6Ck4tULme5MGT7MCRgtfozxoy/6rd/cs33S2HmOvvui7zfL1BLAQIAABQAAAAIAAAAAAA7dLv19AAAAOsDAAAIAAAAAAAAAAAAAAAAAAAAAABpY29uLnBuZ1BLAQIAABQAAAAIAAAAAABcxKZ1wQAAAEoBAAANAAAAAAAAAAEAAAAAABoBAABtYW5pZmVzdC5qc29uUEsBAgAAFAAAAAgAAAAAABCusxqIAQAA3gMAAAoAAAAAAAAAAQAAAAAABgIAAHBvcHVwLmh0bWxQSwECAAAUAAAACAAAAAAARp9Xl1kBAAAMAgAACAAAAAAAAAABAAAAAAC2AwAAcG9wdXAuanNQSwUGAAAAAAQABADfAAAANQUAAAAA"]}}

    The advantage of using this method is that the extension id will always be the same and therefore we can launch the app with a url like chrome-extension://onnbccmmbdfiiedpahdpnombloiokjec/popup.html

PS: The following command will base64 encode the CRX and copy the output to the clipboard.

openssl base64 < /path/to/extension.crx | tr -d '\n' | pbcopy

zacharyc commented 12 years ago

I have run the test and confirmed that the above code installs it with the same extension id of onnbccmmbdfiiedpahdpnombloiokjec

I'm wondering if there isn't a better way to control the extension, but for now that should work.

In order to add this to screening, we will need to add some methods to load a chrome extension. Also, we need to figure out if it is possible to launch in a panel.