Testing a chrome extension using Testcafe with switchToIframe - testing

I've currently got an extension running on testcafe within chrome by having the extension installed on chrome and running: testcafe chrome:userProfile test.js
The content_script in my extension injects an iframe pointing to the web_accessible_resource index.html asset. However when I switch to the iframe context using t.switchToIframe testcafe returns "Content of the iframe to which you are switching did not load"
From what I can see it looks like testcafe-hammerhead isn't rewriting the iframe src when it's in the format of chrome-extension://[PACKAGE ID]/[PATH]) so I've tried changing the url to point to a url i.e. localhost:8080/index.html but this doesn't work either.
If I create an html file inject the iframe using a js file I'm able to get the test to run and interact with the iframe. Therefore I think it's related to how content scripts are run and how they inject content in to the DOM.
Has anyone else run in to this issue/have any better suggestions on how to write tests for extensions in general?
Thanks

Unfortunately, TestCafe doesn't support browser extension testing. TestCafe was designed for cross-browser HTML5 web app testing, so it needs a lot of improvements to cover browser-specific extension APIs.
I suggest you create an issue in the https://github.com/DevExpress/testcafe repository and add +1 to it. If it receives enough votes, we might consider its implementation.

Related

JMeter Screenshotting

I am able to get a screenshot in my JMeter test scripts using the Selenium chrome web driver. This works, but now I want to get screenshots following an authentication request. Is there a way to capture the screen as displayed in the HTTP request?
I don't think there is, theoretically you could try libraries like this one or this one from JSR223 Test Elements using Groovy language, but I don't think you will get what you want
The main reason is given at JMeter project main page:
JMeter is not a browser, it works at protocol level. As far as web-services and remote services are concerned, JMeter looks like a browser (or rather, multiple browsers); however JMeter does not perform all the actions supported by browsers. In particular, JMeter does not execute the Javascript found in HTML pages. Nor does it render the HTML pages as a browser does (it's possible to view the response as HTML etc., but the timings are not included in any samples, and only one sample in one thread is ever displayed at a time).
HTTP Request sampler downloads only HTML, you won't get any images, scripts, styles, fonts, etc. so even if you try to use the aforementioned libraries you will get a "screenshot" which doesn't have anything in common with how does the page look in reality.

How to e2e test websites with disabled JavaScript and noscript tags?

I want to e2e test a website like when a user visits it with disabled javascript and/or some scripts blocked.
cypress.io does not (officially) support testing websites with disabled JS so therefore one can not e2e test what users would see in case they are securely visiting the website without JS enabled.
Nightmare JS seems to support it via browser options to disable JS for each Nightmare instance but I haven't tried its performance yet.
Any suggestions for a 2e2 testing tool that allows my scenario to be tested?
Some testing frameworks do not support this scenario when JavaScript is disabled because they inject their scripts in the tested pages and run them during the test execution. For instance, TestCafe requires JavaScript to inject its scripts.

Front end test automation

I had to recently updgrade from jQuery 1.3 to 1.10. As a result lots jquery code was changed and plugins were upgraded. And consequently this resulted in lot of hours of manual testing.
This got to me think that there should be a better way of testing/validating pages after any js/css change across my site.
I would like to do the following.
crawl all pages on my site.
Check all links on page work correctly
Check for basic html tag validation
Check for any JS & css errors.
jquery version compatible code
Any recommendations for tools that will allow me to perform all of the above test.
Thanks
Free tools exist for quite many of those tasks. There are both web page based validators and browser plugins. I don't know if some tool would do all the below in one or couple steps, but these should get you at least started.
For crawling the site and checking all links you can use tool from The World Wide Web Consortium (W3C):
http://validator.w3.org/checklink
The results page also provides links for for validating html and css of each page.
If you want to validate a file otherwise, you can straight use
http://validator.w3.org/
and
http://www.css-validator.org/
For validating javascript syntax, you can use jslint
Finally, if you want to be more sure that your javascript is working correctly, write unit tests for example with QUnit

Automatically testing UIWebView content with Selenium

I have an iPhone application that contains a UIWebView for rendering certain UI aspects. The UIWebView content communicates with the Objective-C side through NSURLRequests. I'd like to test the UIWebView contents with Selenium so it could be automated.
The problem is the communication with the native side, as this is not supported by Selenium. Therefore, a way is needed to "fake" the Objective-C side. The UIWebView sends requests to a specific (non-existant) URL that are then interpreted by the native code and processed. When running the UIWebView's contents with Selenium, these requests will always fail.
Is there a way to somehow provide support in Selenium that would allow catching these requests and providing a dummy response, or is there a better tool for this?
Preferably, I'd also like to run the Selenium tests with Sauce Labs, or a similar Selenium service, so hacking /etc/hosts is not an option either.
Have you tried Appium? It should allow you to write WebDriver tests that invoke the UIAutomation library.

what is the equivalent option for displaying a notificationbox in chrome extension like in firefox addon

I am developing extensions for a site for major three browsers (FF,Chrome,IE).
I started with firefox and now working with chrome.
I want to know how to implement an option like the firefox xul notificationbox https://developer.mozilla.org/En/XUL:notificationbox in chrome?
How to display the do you want to save password panel in chrome like in firefox notificationbox?
I inspected LastPass and found that they are injecting a div inside the body tag as the first child of the body tag. is that the way it has to be ? or some other option?
There is an experimental API for this: chrome.experimental.infobars.
Until it gets stable creating your own div is the only option.