Skip to content
This repository has been archived by the owner on Dec 27, 2023. It is now read-only.

Integrate privly-applications selenium tests #20

Open
smcgregor opened this issue May 27, 2015 · 15 comments
Open

Integrate privly-applications selenium tests #20

smcgregor opened this issue May 27, 2015 · 15 comments

Comments

@smcgregor
Copy link
Member

The selenium tests found in privly-applications test all the core functionality of the system and will quickly tell you if there is an issue integrating privly-applications with privly-safari. These tests should be supported by the Safari browser's extension context and/or by the Safari web (hosted) context.

Steps:

  1. Install the Safari Driver
  2. Add safari_web and safari_extension to the platforms list along with details.
  3. Add the platforms to this list along with the proper sanity check.
  4. Add the corresponding configurations for safari_web and safari_extension.
  5. Run the tests with ruby run_all.rb --platform safari_web --release-status experimental --content-server http://localhost:3000 For the tests to pass you will need a local content server running on port 3000. You do not need the tests to pass to see that you have configured testing correctly.

I recommend getting this working for safari_web before attempting to test safari_extension.

Completing these steps for TravisCI and SauceLabs will likely be more complicated since it would require somehow installing the safari extension on SauceLabs. This works for the Firefox extension by adding it to the browser's profile from Travis, and it works for the Chrome extension by base64 encoding the extension and streaming it to SauceLabs. One of these approaches will likely work for Safari as well, but the first step is to get these tests running locally without SauceLabs and TravisCI.

@sambuddhabasu
Copy link
Member

@smcgregor Presently, the safari tests run locally and on SauceLabs without the extension.
The next thing I am targeting is to run the selenium tests locally with the extension. I will have to implement a function configure_for_safari_extension but I am not completely sure how to go about it. Can you link me to some documentation or some existing examples which help me do the same?
Thanks

@sambuddhabasu
Copy link
Member

@smcgregor The PR regarding running the tests locally on Safari with the extension is privly/privly-applications#260

@smcgregor
Copy link
Member Author

I think Apple may have removed the ability to programmatically install extensions via Selenium for security reasons. I recommend starting with locally testing the browser extension by pre-installing it to Safari. This will mean you can test the extension from Selenium without installing it from Selenium.

Testing on SauceLabs will be trickier, but let's get local testing running before we starting thinking about that.

@sambuddhabasu
Copy link
Member

@smcgregor I have found https://code.google.com/p/selenium/wiki/RubyBindings#Safari . Though I am not completely sure if this will work, I am currently trying to make this work.
I will also try as you mentioned, to first install the extension and then run the Selenium tests.

@sambuddhabasu
Copy link
Member

@smcgregor Presently, when I install the extension in Safari, I need to know the base URL of the safari extension in order for the tests to run. But, we do not currently get the first run page to know the URL of the extension. What do you think about this?

@smcgregor
Copy link
Member Author

The problem on Chrome is that the URL can cryptographically change depending on whose system they are running their development version on. Is this the case on Safari? Why can't you hard-code the address?

@sambuddhabasu
Copy link
Member

@smcgregor The safari extension have a URL such as safari-extension://com.privly.privly-34B3M269R6/32c12845/. The last 8 characters are alpha-numeric characters which change every time the extension is loaded. Hence, the extension URL cannot be hard-coded.
One way to get the extension URL without going through the first-run page, is to send a message to the extension using the JS console and getting the extension base URL as a response. This way, once we know the extension base URL, we can then set that URL as the base URL for all the selenium tests.
What do you think about this?

@smcgregor
Copy link
Member Author

Ah, ok. I think you should create a version of this file. You will need to add a first-run page for it to work. It basically waits for an extension context page to open then grabs the URL from the page.

@sambuddhabasu
Copy link
Member

@smcgregor Yes, I have tried creating this file but the first-run page on Safari does not load up for tests as the extension is already previously installed.
I am planning to send a message from the test to the extension and getting the extension base URL as the response.

@smcgregor
Copy link
Member Author

Good point. Another option would be to initiate the posting process and to grab the resulting window's URL.

@sambuddhabasu
Copy link
Member

@smcgregor I will open a new PR in the privly-safari repo to support sending a message to the extension and getting back the extension base URL as a response.

@sambuddhabasu
Copy link
Member

Getting the URL from the posting process is an option but getting the URL from the extension sendMessage itself is an easier and a safer option.

@sambuddhabasu
Copy link
Member

@smcgregor Can you explain how to initiate the posting process presently?

@smcgregor
Copy link
Member Author

smcgregor commented Jun 5, 2015 via email

@sambuddhabasu
Copy link
Member

@smcgregor I have now got the extension URL from the injected application of privly's test page. The commit can be seen at sambuddhabasu/privly-applications@dc8e886
Let me know what you think about this.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants