From 2428ae2054fde729ea770b23a4ad67407f0a20ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CCezar=20Augusto=E2=80=9C?= Date: Fri, 3 Feb 2017 18:38:42 -0200 Subject: [PATCH] fix tests dependent of `.tab` / related selectors --- test/about/adblockTest.js | 2 +- test/about/bookmarksManagerTest.js | 4 +-- test/about/braveTest.js | 2 +- test/about/componentUpdaterTest.js | 2 +- test/about/extensionsTest.js | 2 +- test/about/historyTest.js | 4 +-- test/about/newTabTest.js | 6 ++-- test/about/stylesTest.js | 2 +- test/components/contentLoadingTest.js | 4 +-- test/components/findbarTest.js | 5 +-- test/components/frameTest.js | 12 +++---- test/components/navigationBarTest.js | 10 +++--- test/components/pinnedTabTest.js | 24 ++++++------- test/components/tabPagesTest.js | 9 +++-- test/components/tabTest.js | 46 ++++++++++++------------ test/components/urlBarSuggestionsTest.js | 2 +- test/components/urlBarTest.js | 4 +-- test/lib/selectors.js | 12 +++---- 18 files changed, 77 insertions(+), 75 deletions(-) diff --git a/test/about/adblockTest.js b/test/about/adblockTest.js index a6100bc1f25..ced8f50da2e 100644 --- a/test/about/adblockTest.js +++ b/test/about/adblockTest.js @@ -12,7 +12,7 @@ describe('about:adblock', function () { .waitForUrl(Brave.newTabUrl) .waitForBrowserWindow() .waitForVisible(urlInput) - .waitForExist('.tab[data-frame-key="1"]') + .waitForExist('[data-test-id="tab"][data-frame-key="1"]') .tabByIndex(0) .loadUrl(url) }) diff --git a/test/about/bookmarksManagerTest.js b/test/about/bookmarksManagerTest.js index c60e84124ef..fbf333dbe70 100644 --- a/test/about/bookmarksManagerTest.js +++ b/test/about/bookmarksManagerTest.js @@ -45,7 +45,7 @@ describe('about:bookmarks', function () { .addSite({ location: 'https://duckduckgo.com', title: 'duckduckgo', tags: bookmarkTag, parentFolderId: folderId, lastAccessedTime: lastVisit }, siteTags.BOOKMARK) .addSite({ location: 'https://google.com', title: 'Google', tags: bookmarkTag, parentFolderId: folderId, lastAccessedTime: lastVisit }, siteTags.BOOKMARK) .addSite({ location: 'https://bing.com', title: 'Bing', tags: bookmarkTag, parentFolderId: folderId, lastAccessedTime: lastVisit }, siteTags.BOOKMARK) - .waitForExist('.tab[data-frame-key="1"]') + .waitForExist('[data-test-id="tab"][data-frame-key="1"]') .tabByIndex(0) .url(aboutBookmarksUrl) } @@ -60,7 +60,7 @@ describe('about:bookmarks', function () { parentFolderId: 0, lastAccessedTime: lastVisit }, siteTags.BOOKMARK) - .waitForExist('.tab[data-frame-key="1"]') + .waitForExist('[data-test-id="tab"][data-frame-key="1"]') .tabByIndex(0) .url(aboutBookmarksUrl) } diff --git a/test/about/braveTest.js b/test/about/braveTest.js index 8746da0c2eb..b5e346ce18c 100644 --- a/test/about/braveTest.js +++ b/test/about/braveTest.js @@ -12,7 +12,7 @@ describe('about:brave tests', function () { .waitForUrl(Brave.newTabUrl) .waitForBrowserWindow() .waitForVisible(urlInput) - .waitForExist('.tab[data-frame-key="1"]') + .waitForExist('[data-test-id="tab"][data-frame-key="1"]') .tabByIndex(0) .loadUrl(url) }) diff --git a/test/about/componentUpdaterTest.js b/test/about/componentUpdaterTest.js index 6cb26da8755..0504856472b 100644 --- a/test/about/componentUpdaterTest.js +++ b/test/about/componentUpdaterTest.js @@ -11,7 +11,7 @@ describe('component updater', function () { .waitForBrowserWindow() .waitForVisible(urlInput) .windowByUrl(Brave.browserWindowUrl) - .waitForExist('.tab[data-frame-key="1"]') + .waitForExist('[data-test-id="tab"][data-frame-key="1"]') } describe('Google Widevine is disabled by default', function () { diff --git a/test/about/extensionsTest.js b/test/about/extensionsTest.js index d3e31743712..b71dd0f49c6 100644 --- a/test/about/extensionsTest.js +++ b/test/about/extensionsTest.js @@ -15,7 +15,7 @@ describe('about:extensions', function () { .waitForBrowserWindow() .waitForVisible(urlInput) .windowByUrl(Brave.browserWindowUrl) - .waitForExist('.tab[data-frame-key="1"]') + .waitForExist('[data-test-id="tab"][data-frame-key="1"]') .tabByIndex(0) .url(aboutExtensionsUrl) } diff --git a/test/about/historyTest.js b/test/about/historyTest.js index d7cd4548ac3..6c434408d49 100644 --- a/test/about/historyTest.js +++ b/test/about/historyTest.js @@ -23,7 +23,7 @@ describe('about:history', function () { .addSite({ location: 'https://brave.com/test', customTitle: 'customTest' }) .addSite({ location: 'https://www.youtube.com' }) .addSite({ location: 'https://www.facebook.com' }) - .waitForExist('.tab[data-frame-key="1"]') + .waitForExist('[data-test-id="tab"][data-frame-key="1"]') .tabByIndex(0) .url(aboutHistoryUrl) } @@ -35,7 +35,7 @@ describe('about:history', function () { location: site, title: 'Page 1' }) - .waitForExist('.tab[data-frame-key="1"]') + .waitForExist('[data-test-id="tab"][data-frame-key="1"]') .tabByIndex(0) .url(aboutHistoryUrl) } diff --git a/test/about/newTabTest.js b/test/about/newTabTest.js index 7ba014813f5..ee259e252d2 100644 --- a/test/about/newTabTest.js +++ b/test/about/newTabTest.js @@ -60,7 +60,7 @@ describe('about:newtab tests', function () { .addSite({ location: 'about:preferences' }) .addSite({ location: 'about:safebrowsing' }) .addSite({ location: 'about:styles' }) - .waitForExist('.tab[data-frame-key="1"]') + .waitForExist('[data-test-id="tab"][data-frame-key="1"]') .tabByIndex(0) .url(aboutNewTabUrl) } @@ -68,7 +68,7 @@ describe('about:newtab tests', function () { function * waitForPageLoad (client) { yield client .windowByUrl(Brave.browserWindowUrl) - .waitForExist('.tab[data-frame-key="1"]') + .waitForExist('[data-test-id="tab"][data-frame-key="1"]') .tabByIndex(0) } @@ -120,7 +120,7 @@ describe('about:newtab tests', function () { yield this.app.client .windowByUrl(Brave.browserWindowUrl) - .waitForExist('.tab[data-frame-key="1"]') + .waitForExist('[data-test-id="tab"][data-frame-key="1"]') .tabByIndex(0) .waitForVisible('.clock .time') .waitUntil(function () { diff --git a/test/about/stylesTest.js b/test/about/stylesTest.js index 2b72e2be20f..06f9864d661 100644 --- a/test/about/stylesTest.js +++ b/test/about/stylesTest.js @@ -12,7 +12,7 @@ describe('about:styles', function () { .waitForUrl(Brave.newTabUrl) .waitForBrowserWindow() .waitForVisible(urlInput) - .waitForExist('.tab[data-frame-key="1"]') + .waitForExist('[data-test-id="tab"][data-frame-key="1"]') .tabByIndex(0) .loadUrl(url) }) diff --git a/test/components/contentLoadingTest.js b/test/components/contentLoadingTest.js index 9f878bbcd08..4259ada4cfa 100644 --- a/test/components/contentLoadingTest.js +++ b/test/components/contentLoadingTest.js @@ -23,7 +23,7 @@ describe('content loading', function () { .url(page1) .windowByUrl(Brave.browserWindowUrl) .waitUntil(function () { - return this.getText('.tabTitle').then((title) => { + return this.getText('[data-test-id="tabTitle"]').then((title) => { return title === 'failed' }) }) @@ -36,7 +36,7 @@ describe('content loading', function () { .url(page1) .windowByUrl(Brave.browserWindowUrl) .waitUntil(function () { - return this.getText('.tabTitle').then((title) => { + return this.getText('[data-test-id="tabTitle"]').then((title) => { return title === 'fail' }) }) diff --git a/test/components/findbarTest.js b/test/components/findbarTest.js index dddf35ba088..4d123e509be 100644 --- a/test/components/findbarTest.js +++ b/test/components/findbarTest.js @@ -234,11 +234,12 @@ describe('findBar', function () { .showFindbar(true, 2) .waitForElementFocus(findBarInput) .setValue(findBarInput, 'abc') - .click('.tab') + .click('[data-test-id="tab"]') .waitUntil(function () { return this.getValue(findBarInput).then((val) => val === 'test') }) - .click('.closeTab') + .click('[data-test-id="tab"]') + .click('[data-test-id="closeTabIcon"]') .waitUntil(function () { return this.getValue(findBarInput).then((val) => val === 'abc') }) diff --git a/test/components/frameTest.js b/test/components/frameTest.js index 24d747fb0e3..2592d42fbce 100644 --- a/test/components/frameTest.js +++ b/test/components/frameTest.js @@ -55,7 +55,7 @@ describe('frame tests', function () { .click('#name') yield this.app.client .windowByUrl(Brave.browserWindowUrl) - .waitForExist('.tab[data-frame-key="2"]') + .waitForExist('[data-test-id="tab"][data-frame-key="2"]') yield this.app.client .ipcSend('shortcut-set-active-frame-by-index', 0) .windowByUrl(Brave.browserWindowUrl) @@ -64,9 +64,9 @@ describe('frame tests', function () { }) it('inserts after the tab to clone', function * () { - this.tab1 = '.tabArea:nth-child(1) .tab[data-frame-key="1"]' - this.tab2 = '.tabArea:nth-child(2) .tab[data-frame-key="3"]' - this.tab3 = '.tabArea:nth-child(3) .tab[data-frame-key="2"]' + this.tab1 = '.tabArea:nth-child(1) [data-test-id="tab"][data-frame-key="1"]' + this.tab2 = '.tabArea:nth-child(2) [data-test-id="tab"][data-frame-key="3"]' + this.tab3 = '.tabArea:nth-child(3) [data-test-id="tab"][data-frame-key="2"]' yield this.app.client .windowByUrl(Brave.browserWindowUrl) .waitForExist(this.tab1) @@ -185,7 +185,7 @@ describe('frame tests', function () { .tabByIndex(0) .loadUrl(this.url) .windowByUrl(Brave.browserWindowUrl) - .waitForExist('.tab[data-frame-key="1"]') + .waitForExist('[data-test-id="tab"][data-frame-key="1"]') .waitForExist(this.webview1) }) @@ -214,7 +214,7 @@ describe('frame tests', function () { yield setup(this.app.client) yield this.app.client .windowByUrl(Brave.browserWindowUrl) - .waitForExist('.tab[data-frame-key="1"]') + .waitForExist('[data-test-id="tab"][data-frame-key="1"]') }) it('loads an image', function * () { diff --git a/test/components/navigationBarTest.js b/test/components/navigationBarTest.js index fa7e3cf7009..b53e5e48d41 100644 --- a/test/components/navigationBarTest.js +++ b/test/components/navigationBarTest.js @@ -380,8 +380,8 @@ describe('navigationBar tests', function () { const pageWithNoFavicon = Brave.server.url('page_no_favicon.html') yield this.app.client.tabByUrl(Brave.newTabUrl).url(pageWithNoFavicon).waitForUrl(pageWithNoFavicon).windowParentByUrl(pageWithNoFavicon) yield this.app.client.waitUntil(function () { - return this.getAttribute(activeTabFavicon, 'class').then((className) => - className === 'tabIcon bookmarkFile fa fa-file-o') + return this.getAttribute('[data-test-id="defaultIcon"]', 'class').then((className) => + className === 'fa fa-file-o') }) }) }) @@ -759,8 +759,8 @@ describe('navigationBar tests', function () { it('Uses the default tab color when one is not specified', function * () { const page1Url = Brave.server.url('page1.html') yield this.app.client.tabByUrl(Brave.newTabUrl).url(page1Url).waitForUrl(page1Url).windowParentByUrl(page1Url) - let background = yield this.app.client.getCssProperty(activeTab, 'background') - assert.equal(background.value, 'rgba(0,0,0,0)linear-gradient(white,rgb(243,243,243))repeatscroll0%0%/autopadding-boxborder-box') + let background = yield this.app.client.getCssProperty('[data-test-active-tab]', 'background') + assert.equal(background.value, 'rgba(0,0,0,0)linear-gradient(rgb(255,255,255),rgb(243,243,243))repeatscroll0%0%/autopadding-boxborder-box') }) // We need a newer electron build first @@ -1089,7 +1089,7 @@ describe('navigationBar tests', function () { it('focuses on the urlbar', function * () { this.app.client - .waitForExist('.tab[data-frame-key="1"].active') + .waitForExist('[data-test-active-tab][data-frame-key="1"]') .waitForElementFocus(urlInput) }) }) diff --git a/test/components/pinnedTabTest.js b/test/components/pinnedTabTest.js index 377cfaaf7f2..8ff70eac46e 100644 --- a/test/components/pinnedTabTest.js +++ b/test/components/pinnedTabTest.js @@ -23,7 +23,7 @@ describe('pinnedTabs', function () { .ipcSend(messages.SHORTCUT_NEW_FRAME, this.page1Url) .waitForUrl(this.page1Url) .windowByUrl(Brave.browserWindowUrl) - .waitForExist('.tab[data-frame-key="2"]') + .waitForExist('[data-test-id="tab"][data-frame-key="2"]') .setPinned(this.page1Url, true) .waitForExist(pinnedTabsTabs) .waitForElementCount(pinnedTabsTabs, 1) @@ -31,12 +31,12 @@ describe('pinnedTabs', function () { }) it('creates when signaled', function * () { yield this.app.client - .waitForExist('.tab.isPinned[data-frame-key="2"]') + .waitForExist('[data-test-pinned-tab][data-frame-key="2"]') }) it('unpins and creates a non-pinned tab', function * () { yield this.app.client .setPinned(this.page1Url, false) - .waitForExist('.tab:not(.isPinned)[data-frame-key="2"]') + .waitForExist('[data-test-pinned-tab="false"][data-frame-key="2"]') .waitForElementCount(pinnedTabsTabs, 0) .waitForElementCount(tabsTabs, 2) }) @@ -45,7 +45,7 @@ describe('pinnedTabs', function () { .ipcSend(messages.SHORTCUT_NEW_FRAME, this.page1Url) .waitForUrl(this.page1Url) .windowByUrl(Brave.browserWindowUrl) - .waitForExist('.tab[data-frame-key="3"]') + .waitForExist('[data-test-id="tab"][data-frame-key="3"]') .setPinned(this.page1Url, true) .waitForElementCount(pinnedTabsTabs, 1) .waitForElementCount(tabsTabs, 2) @@ -61,13 +61,13 @@ describe('pinnedTabs', function () { .ipcSend(messages.SHORTCUT_NEW_FRAME, this.page1Url) .waitForUrl(this.page1Url) .windowByUrl(Brave.browserWindowUrl) - .waitForExist('.tab[data-frame-key="2"]') + .waitForExist('[data-test-id="tab"][data-frame-key="2"]') .setPinned(this.page1Url, true) .waitForExist(pinnedTabsTabs) .waitForElementCount(pinnedTabsTabs, 1) .waitForElementCount(tabsTabs, 1) .ipcSend(messages.SHORTCUT_NEW_FRAME, this.page1Url, {partitionNumber: 1}) - .waitForExist('.tab[data-frame-key="3"]') + .waitForExist('[data-test-id="tab"][data-frame-key="3"]') .setPinned(this.page1Url, true, {partitionNumber: 1}) .waitForElementCount(pinnedTabsTabs, 2) .waitForElementCount(tabsTabs, 1) @@ -84,11 +84,11 @@ describe('pinnedTabs', function () { .addSite({ location: page1Url }, siteTags.PINNED) .waitForUrl(page1Url) .windowByUrl(Brave.browserWindowUrl) - .waitForExist('.tab.isPinned[data-frame-key="2"]') + .waitForExist('[data-test-pinned-tab][data-frame-key="2"]') .addSite({ location: page2Url }, siteTags.PINNED) .waitForUrl(page2Url) .windowByUrl(Brave.browserWindowUrl) - .waitForExist('.tab.isPinned[data-frame-key="3"]') + .waitForExist('[data-test-pinned-tab][data-frame-key="3"]') }) it('creates when signaled', function * () { yield this.app.client.waitUntil(function () { @@ -132,7 +132,7 @@ describe('pinnedTabs', function () { .ipcSend(messages.SHORTCUT_NEW_FRAME, this.page1Url) .waitForUrl(this.page1Url) .windowByUrl(Brave.browserWindowUrl) - .waitForExist('.tab[data-frame-key="2"]') + .waitForExist('[data-test-id="tab"][data-frame-key="2"]') .setPinned(this.page1Url, true) .waitForExist(pinnedTabsTabs) }) @@ -171,13 +171,13 @@ describe('pinnedTabs', function () { .waitForElementCount(pinnedTabsTabs, 1) .waitForElementCount(tabsTabs, 1) .click(pinnedTabsTabs) - .waitForElementCount(pinnedTabsTabs + '.active', 1) + .waitForElementCount(pinnedTabsTabs + '[data-test-active-tab]', 1) }) it('close attempt retains pinned tab and selects next active frame', function * () { yield this.app.client - .waitForExist('.tab.active[data-frame-key="2"]') + .waitForExist('[data-test-active-tab][data-frame-key="2"]') .ipcSend(messages.SHORTCUT_CLOSE_FRAME) - .waitForExist('.tab.active[data-frame-key="1"]') + .waitForExist('[data-test-active-tab][data-frame-key="1"]') }) }) }) diff --git a/test/components/tabPagesTest.js b/test/components/tabPagesTest.js index ecd118ada50..4cafd7cce21 100644 --- a/test/components/tabPagesTest.js +++ b/test/components/tabPagesTest.js @@ -3,7 +3,7 @@ const Brave = require('../lib/brave') const appConfig = require('../../js/constants/appConfig') const settings = require('../../js/constants/settings') -const {urlInput, newFrameButton, tabsTabs, tabPage, tabPage1, tabPage2, closeTab, activeWebview} = require('../lib/selectors') +const {urlInput, newFrameButton, tabsTabs, tabPage, tabPage1, tabPage2, activeWebview} = require('../lib/selectors') describe('tab pages', function () { function * setup (client) { @@ -35,12 +35,15 @@ describe('tab pages', function () { }) it('shows no tab pages when you have only 1 page', function * () { - yield this.app.client.click(closeTab) + yield this.app.client + .waitForExist('[data-test-id="tab"][data-frame-key="1"]') + .click('[data-test-active-tab]') + .click('[data-test-id="closeTabIcon"]') .waitForElementCount(tabPage, 0) }) it('focuses active tab\'s page when closing last tab on page', function * () { - yield this.app.client.waitForVisible('.tab.active') + yield this.app.client.waitForVisible('[data-test-active-tab]') }) describe('allows changing to tab pages', function () { diff --git a/test/components/tabTest.js b/test/components/tabTest.js index 19f396db402..d92e18d566b 100644 --- a/test/components/tabTest.js +++ b/test/components/tabTest.js @@ -67,7 +67,7 @@ describe('tab tests', function () { it('creates a new tab when signaled', function * () { yield this.app.client .ipcSend(messages.SHORTCUT_NEW_FRAME) - .waitForExist('.tab[data-frame-key="2"]') + .waitForExist('[data-test-id="tab"][data-frame-key="2"]') }) it('makes the non partitioned webview visible', function * () { @@ -85,7 +85,7 @@ describe('tab tests', function () { it('creates a new tab when clicked', function * () { yield this.app.client .click(newFrameButton) - .waitForExist('.tab[data-frame-key="2"]') + .waitForExist('[data-test-id="tab"][data-frame-key="2"]') }) it('shows a context menu when long pressed (click and hold)', function * () { yield this.app.client @@ -111,9 +111,9 @@ describe('tab tests', function () { it('creates a new tab when signaled', function * () { yield this.app.client .ipcSend(messages.SHORTCUT_NEW_FRAME, 'about:blank', { openInForeground: false }) - .waitForExist('.tab[data-frame-key="2"]') + .waitForExist('[data-test-id="tab"][data-frame-key="2"]') .ipcSend(messages.SHORTCUT_NEW_FRAME, 'about:blank') - .waitForExist('.tabArea + .tabArea + .tabArea .tab[data-frame-key="3"') + .waitForExist('.tabArea + .tabArea + .tabArea [data-test-id="tab"][data-frame-key="3"]') }) }) describe('respects parentFrameKey', function () { @@ -125,9 +125,9 @@ describe('tab tests', function () { it('creates a new tab when signaled', function * () { yield this.app.client .ipcSend(messages.SHORTCUT_NEW_FRAME, 'about:blank', { openInForeground: false }) - .waitForExist('.tab[data-frame-key="2"]') + .waitForExist('[data-test-id="tab"][data-frame-key="2"]') .ipcSend(messages.SHORTCUT_NEW_FRAME, 'about:blank', { parentFrameKey: 1 }) - .waitForExist('.tabArea:nth-child(2) .tab[data-frame-key="3"]') + .waitForExist('.tabArea:nth-child(2) [data-test-id="tab"][data-frame-key="3"]') }) }) }) @@ -144,7 +144,7 @@ describe('tab tests', function () { }) it('creates a new private tab', function * () { yield this.app.client - .waitForExist('.tab.private[data-frame-key="2"]') + .waitForExist('[data-test-private-tab][data-frame-key="2"]') }) it('makes the private webview visible', function * () { yield this.app.client @@ -164,7 +164,7 @@ describe('tab tests', function () { }) it('creates a new session tab', function * () { yield this.app.client - .waitForExist('.tab[data-frame-key="2"]') + .waitForExist('[data-test-id="tab"][data-frame-key="2"]') }) it('makes the new session webview visible', function * () { yield this.app.client @@ -184,7 +184,7 @@ describe('tab tests', function () { }) it('creates a new session tab', function * () { yield this.app.client - .waitForExist('.tab[data-frame-key="2"]') + .waitForExist('[data-test-id="tab"][data-frame-key="2"]') }) it('makes the new session webview visible', function * () { yield this.app.client @@ -202,7 +202,7 @@ describe('tab tests', function () { it('can close a normal tab', function * () { yield this.app.client .waitForBrowserWindow() - .waitForExist('.tab.active[data-frame-key="1"]') + .waitForExist('[data-test-active-tab][data-frame-key="1"]') .ipcSend(messages.SHORTCUT_NEW_FRAME) .waitUntil(function () { return this.waitForUrl(Brave.newTabUrl) @@ -221,7 +221,7 @@ describe('tab tests', function () { .waitForBrowserWindow() .windowByUrl(Brave.browserWindowUrl) .ipcSend(messages.SHORTCUT_NEW_FRAME, Brave.server.url('page1.html'), {frameOpts: {unloaded: true, location: Brave.server.url('page1.html'), title: 'hi', tabId: null}, openInForeground: false}) - .waitForElementCount('.tab', 2) + .waitForElementCount('[data-test-id="tab"]', 2) // This ensures it's actually unloaded .waitForTabCount(1) .windowByUrl(Brave.browserWindowUrl) @@ -231,7 +231,7 @@ describe('tab tests', function () { it('should undo last closed tab', function * () { yield this.app.client .waitForBrowserWindow() - .waitForExist('.tab.active[data-frame-key="1"]') + .waitForExist('[data-test-active-tab][data-frame-key="1"]') .ipcSend(messages.SHORTCUT_NEW_FRAME, Brave.server.url('page1.html')) .waitUntil(function () { return this.waitForUrl(Brave.newTabUrl) @@ -265,24 +265,24 @@ describe('tab tests', function () { .ipcSend(messages.SHORTCUT_NEW_FRAME, page1) .waitForUrl(page1) .windowByUrl(Brave.browserWindowUrl) - .waitForExist('.tab[data-frame-key="2"]') + .waitForExist('[data-test-id="tab"][data-frame-key="2"]') .ipcSend(messages.SHORTCUT_NEW_FRAME, page2) .waitForUrl(page2) .windowByUrl(Brave.browserWindowUrl) - .waitForExist('.tab[data-frame-key="3"]') + .waitForExist('[data-test-id="tab"][data-frame-key="3"]') }) it('shows a tab preview', function * () { yield this.app.client - .moveToObject('.tab[data-frame-key="2"]') - .moveToObject('.tab[data-frame-key="2"]', 3, 3) + .moveToObject('[data-test-id="tab"][data-frame-key="2"]') + .moveToObject('[data-test-id="tab"][data-frame-key="2"]', 3, 3) .waitForExist('.frameWrapper.isPreview webview[data-frame-key="2"]') .moveToObject(urlInput) }) it('does not show tab previews when setting is off', function * () { yield this.app.client.changeSetting(settings.SHOW_TAB_PREVIEWS, false) yield this.app.client - .moveToObject('.tab[data-frame-key="2"]') - .moveToObject('.tab[data-frame-key="2"]', 3, 3) + .moveToObject('[data-test-id="tab"][data-frame-key="2"]') + .moveToObject('[data-test-id="tab"][data-frame-key="2"]', 3, 3) try { yield this.app.client.waitForExist('.frameWrapper.isPreview webview[data-frame-key="2"]', 1000) } catch (e) { @@ -303,7 +303,7 @@ describe('tab tests', function () { .ipcSend(messages.SHORTCUT_NEW_FRAME, url, {openInForeground: false}) .waitForUrl(url) .windowByUrl(Brave.browserWindowUrl) - .waitForExist('.tab[data-frame-key="2"]') + .waitForExist('[data-test-id="tab"][data-frame-key="2"]') yield this.app.client.waitForExist('.frameWrapper:not(.isActive) webview[data-frame-key="2"]') }) it('changing new tab default makes new tabs open in background by default', function * () { @@ -313,7 +313,7 @@ describe('tab tests', function () { .ipcSend(messages.SHORTCUT_NEW_FRAME, url, {openInForeground: false}) .waitForUrl(url) .windowByUrl(Brave.browserWindowUrl) - .waitForExist('.tab[data-frame-key="3"]') + .waitForExist('[data-test-id="tab"][data-frame-key="3"]') yield this.app.client.waitForExist('.frameWrapper.isActive webview[data-frame-key="3"]') }) }) @@ -325,7 +325,7 @@ describe('tab tests', function () { }) it('shows tab\'s icon when page is not about:blank or about:newtab ', function * () { - var url = Brave.server.url('page1.html') + var url = Brave.server.url('favicon.html') yield this.app.client .tabByIndex(0) .loadUrl(url) @@ -351,9 +351,9 @@ describe('tab tests', function () { it('has untitled text right away', function * () { yield this.app.client .ipcSend(messages.SHORTCUT_NEW_FRAME, 'about:blank', { openInForeground: false }) - .waitForVisible('.tab[data-frame-key="2"]') + .waitForVisible('[data-test-id="tab"][data-frame-key="2"]') // This should not be converted to a waitUntil - .getText('.tab[data-frame-key="2"]').then((val) => assert.equal(val, 'Untitled')) + .getText('[data-test-id="tab"][data-frame-key="2"]').then((val) => assert.equal(val, 'Untitled')) }) }) }) diff --git a/test/components/urlBarSuggestionsTest.js b/test/components/urlBarSuggestionsTest.js index cb7d0077f69..9c68d468d03 100644 --- a/test/components/urlBarSuggestionsTest.js +++ b/test/components/urlBarSuggestionsTest.js @@ -31,7 +31,7 @@ describe('urlBarSuggestions', function () { .ipcSend(messages.SHORTCUT_NEW_FRAME) .waitForUrl(Brave.newTabUrl) .windowByUrl(Brave.browserWindowUrl) - .waitForExist('.tab[data-frame-key="2"].active') + .waitForExist('[data-test-active-tab][data-frame-key="2"]') .waitForElementFocus(urlInput) }) diff --git a/test/components/urlBarTest.js b/test/components/urlBarTest.js index b4ff660761f..4456f20e538 100644 --- a/test/components/urlBarTest.js +++ b/test/components/urlBarTest.js @@ -413,11 +413,11 @@ describe('urlBar tests', function () { .waitUntil(function () { return this.getValue(urlInput).then((val) => val === coffee) }) - .click('.tab[data-frame-key="1"]') + .click('[data-test-id="tab"][data-frame-key="1"]') .waitUntil(function () { return this.getValue(urlInput).then((val) => val !== coffee) }) - .click('.tab[data-frame-key="2"]') + .click('[data-test-id="tab"][data-frame-key="2"]') .waitUntil(function () { return this.getValue(urlInput).then((val) => val === coffee) }) diff --git a/test/lib/selectors.js b/test/lib/selectors.js index c0494019f23..9ee20d4d685 100644 --- a/test/lib/selectors.js +++ b/test/lib/selectors.js @@ -4,19 +4,17 @@ module.exports = { closeButton: '.close-btn', urlInput: '#urlInput', activeWebview: '.frameWrapper.isActive webview', - activeTab: '.tab.active', - activeTabTitle: '.tab.active .tabTitle', - activeTabFavicon: '.tab.active .tabIcon', - pinnedTabs: '.pinnedTabs', - pinnedTabsTabs: '.pinnedTabs .tab', - tabsTabs: '.tabs .tab', + activeTabTitle: '[data-test-active-tab] [data-test-id="tabTitle"]', + activeTabFavicon: '[data-test-active-tab] [data-test-favicon]', + pinnedTabsTabs: '.pinnedTabs [data-test-id="tab"]', + tabsTabs: '.tabs [data-test-id="tab"]', navigator: '#navigator', navigatorLoadTime: '#navigator .loadTime', newFrameButton: '.tabs .newFrameButton', tabPage: '.tabPage', tabPage1: '[data-tab-page="0"]', tabPage2: '[data-tab-page="1"]', - closeTab: '.closeTab', + closeTab: '[data-test-id="closeTabIcon"]', urlbarIcon: '.urlbarIcon', urlBarSuggestions: '.urlBarSuggestions', titleBar: '#titleBar',