Methods for Capturing Visual Context

Integrate With Browser Automation Software

If you use browser automation software - such as Selenium, PhantomJS - for testing purposes, you can set up the Chrome Context Capture Extension to integrate with your existing test scripts and take a snapshot and any point in a script.

  1. In Chrome > Preferences > Extensions, find the Chrome Context Capture Extension, and click Options.
  2. Check Detect Automation.
    integrate.png
  3. To take a snapshot during automation, add this code to your script, substituting your Project ID and API Key.

JavaScript:

fireSmartlingChromeExtension({
        "projectId": "projectUID",
        "apiKey":"project-api-key",
        "callback":function(submissionData){
             /* snapshot is submitted, move on */
        }
});

Override Existing Context

By default, the Chrome Context Capture Extension will not override existing context, but this behavior can be customized by using your automation script to apply Smartling HTML classes to a page or to specific elements in the DOM.

To override context for an entire page:

Add the two classes sl-override-context and sl-translate to the page’s HTML tag.

To override context for specific elements on the page:

  1. Add the sl-notranslate class to the HTML tag of the page.
  2. Add the two classes sl-override-context and sl-translate to the elements you want to override context for. Any nested child elements will also be overwritten.
Was this article helpful?