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

Commit

Permalink
Fix #3306, make tests resilient to a browserAction or pageAction
Browse files Browse the repository at this point in the history
Also the label changed for unknown (but presumably unimportant) reasons
  • Loading branch information
ianb committed Aug 10, 2017
1 parent 458c203 commit 5b648db
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ const { By, until } = webdriver;
const path = require("path");

const SHOOTER_BUTTON_ID = "pageAction-panel-screenshots";
// Applies to the old-style toolbar button:
const TOOLBAR_SHOOTER_BUTTON_ID = "screenshots_mozilla_org-browser-action";
const shooterSelector = By.css(`#${SHOOTER_BUTTON_ID}, #${TOOLBAR_SHOOTER_BUTTON_ID}`);
const SLIDE_IFRAME_ID = "firefox-screenshots-onboarding-iframe";
const PRESELECTION_IFRAME_ID = "firefox-screenshots-preselection-iframe";
const PREVIEW_IFRAME_ID = "firefox-screenshots-preview-iframe";
Expand Down Expand Up @@ -118,7 +121,7 @@ function promiseFinally(promise, finallyCallback) {
successfully. */
function startScreenshots(driver) {
return promiseFinally(
getChromeElement(driver, By.id(SHOOTER_BUTTON_ID)).then((button) => {
getChromeElement(driver, shooterSelector).then((button) => {
return button.click();
}),
() => {
Expand Down Expand Up @@ -219,10 +222,14 @@ describe("Test Screenshots", function() {
it("should find the add-on button", function() {
this.timeout(15000);
return promiseFinally(
getChromeElement(driver, By.id(SHOOTER_BUTTON_ID))
getChromeElement(driver, shooterSelector)
.then((button) => button.getAttribute("label"))
.then((label) => {
assert.equal(label, "Take a Screenshot");
if (label == "Take a Screenshot") {
assert.equal(label, "Take a Screenshot");
} else {
assert.equal(label, "Firefox Screenshots");
}
}),
() => {
driver.setContext(firefox.Context.CONTENT);
Expand Down

0 comments on commit 5b648db

Please # to comment.