Hello,
I'm trying to use TestComplete to test a Chrome extension that is currently in development. When I click on the icon it will display a popup like so:
As far as I know there is no way to reliably target and click the icon. Please let me know if there is.
Since the popup is actually another webpage (this is just how chrome extensions work) I tried to work around this by opening it by itself. You can do this by opening a url like chrome-extension://<extention-unique-id>/popup.html
So now I have a web page like this:
But for some reason, I cannot find the 'Take Screenshot' button in TestComplete.
It finds the page but it does not have any children
Here is the HTML for the page:
<html> <head> <style> button { white-space: nowrap; outline: none; } </style> </head> <body> <button id="takeScreenshot">Take Screenshot</button> <script src="popup.js"></script> </body> </html>
Does anyone have any ideas/experiance testing chrome extensions? I came up with this method from this selenium post so I know it's possible
Thanks!
This is one of the few cases where I'd suggest using FindChildByXPath. My guess is that the button is not recognized by TestComplete's engine as a UI component because it doesn't match some sort of pattern. So, an XPath search may find the button and allow you to interact with it.
I tried FindChildByXPath but no luck...
I'm noticed that the SmartBear extension doesn't inject the hidden nodes that it normally does in other pages.
When I right click on the extension while my chrome extension page is open I see:
I think this is a chrome limitation. It doesn't allow us to inject into it's internal pages.
For security considerations Chrome refuses all extensions to inject code into its internal pages (about:*, chrome:*). Because of that, internal pages, like the new tab page, the extension manager, the download manager, the history page and so on, are not accessible to TestComplete.
Source: https://support.smartbear.com/testcomplete/docs/app-testing/web/general/considerations.html
I may need to switch to selenium for this one... It doesn't have this limitation.
Hi,
I am afraid that you are referencing help topic that describes exactly the reason of the problem.
One quick idea meanwhile:
-- If TestComplete Object Browser can access internals of the .contentDocument property, you may try to search for and work with web elements via native DOM functions like it is described in the https://support.smartbear.com/testcomplete/docs/reference/test-objects/members/page/contentdocument-... and https://support.smartbear.com/testcomplete/docs/app-testing/web/general/common-tasks/javascript.html help topics.
Hi @thePantz,
Because of the Chrome specifics, TestComplete can only get access to the viewport of the browser - the actual pages you visit. That's why currently there is no way to recognize elements in extension popups. As far as I know, the same goes for Selenium - it only allows you to work with the popup if you open it in Chrome as an individual HTML page, but TestComplete has no issues with this scenario as well.
As a workaround, I can suggest using the image-based approach - finding elements by their images. You can also use Optical Character Recognition to obtain elements by their text (please note that it requires a separate license for the TC IQ add-on).
@AlexKaras I'm afraid the .contentDocument I get is null in this case. However it is visible if I change my my Web Object Model from a Tree View Model to a DOM Model
The DOM model is a deprecated web testing mode which might cause issues with performance, so
I suggest you stick with the Tree model.
@JuliaBernikova As I explained in my original post, TestComplete cannot locate the elements when you open the popup on an indivudual page. I did not have difficulties when using Selenium so I have gone that route. I will not pay for an Image Recognition module when I can get more reliable results from Selenium.
I should have put it differently: by an individual HTML page, I meant opening HTML locally as a file, not via chrome-extension://. It's good to know that Selenium supports this mode though - the next TestComplete version will introduce a cross-platform web testing feature that allows running tests using Selenium Grid. So, our product team will check if we can make TestComplete work with chrome-extension:// pages too.
Subject | Author | Latest Post |
---|---|---|