[Libreoffice-commits] online.git: cypress_test/integration_tests

Tamás Zolnai (via logerrit) logerrit at kemper.freedesktop.org
Thu Apr 9 10:19:08 UTC 2020


 cypress_test/integration_tests/common/helper.js                             |   22 ++++
 cypress_test/integration_tests/common/mobile_helper.js                      |    9 -
 cypress_test/integration_tests/desktop/copy_paste_spec.js                   |    6 -
 cypress_test/integration_tests/mobile/calc/apply_font_spec.js               |   14 +-
 cypress_test/integration_tests/mobile/calc/insertion_wizard_spec.js         |   23 +---
 cypress_test/integration_tests/mobile/calc/number_format_spec.js            |    6 -
 cypress_test/integration_tests/mobile/calc/spellchecking_spec.js            |   24 +---
 cypress_test/integration_tests/mobile/impress/spellchecking_spec.js         |   24 +---
 cypress_test/integration_tests/mobile/writer/apply_font_spec.js             |   19 +--
 cypress_test/integration_tests/mobile/writer/focus_spec.js                  |   15 +-
 cypress_test/integration_tests/mobile/writer/insert_field_spec.js           |   28 +----
 cypress_test/integration_tests/mobile/writer/insert_formatting_mark_spec.js |   24 +---
 cypress_test/integration_tests/mobile/writer/insert_object_spec.js          |   54 +++-------
 cypress_test/integration_tests/mobile/writer/mobile_wizard_state_spec.js    |    8 -
 cypress_test/integration_tests/mobile/writer/shape_properties_spec.js       |    6 -
 cypress_test/integration_tests/mobile/writer/spellchecking_spec.js          |   54 ++++------
 cypress_test/integration_tests/mobile/writer/toolbar_spec.js                |    2 
 cypress_test/integration_tests/mobile/writer/writer_helper.js               |   12 --
 18 files changed, 148 insertions(+), 202 deletions(-)

New commits:
commit 354f667c83bfe78cb4dd3dbb593b5412fcb51b06
Author:     Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Wed Apr 8 19:24:16 2020 +0200
Commit:     Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Thu Apr 9 12:18:50 2020 +0200

    cypress: introduce selectItemByContent() method instead of contains().
    
    cy.get().contains() behaves unexpectedly. With pseudo code:
    
    // First find the item using the selector
    do {
      item = get(selector)
    } while (item == undefined)
    
    // Then wait until it get's the right content.
    // Item points to an object which can change it time.
    do {
    } while (item.content != specified_content)
    
    
    What we actually need is something like this:
    // Wait for an item which matches both the selector and content.
    do {
      item = get(selector)
    } while (item == undefined || item.content != specified_content)
    
    The new selectItemByContent() method behaves like this.
    
    It just looks wierd when you experience a test failure in the
    interactive test runner and you check the DOM and you can see
    the right item with the rigth content and the test still fails.
    
    Change-Id: I0b1466a165451e831401e1f4b500ce16bd3f38b0
    Signed-off-by: Tamás Zolnai <tamas.zolnai at collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/91955
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>

diff --git a/cypress_test/integration_tests/common/helper.js b/cypress_test/integration_tests/common/helper.js
index 795973a55..9eab3b5b1 100644
--- a/cypress_test/integration_tests/common/helper.js
+++ b/cypress_test/integration_tests/common/helper.js
@@ -154,6 +154,27 @@ function afterAll(fileName) {
 	cy.log('Waiting for closing the document - end.');
 }
 
+// There is no css selector for filtering based on
+// the content of an item. cypress has Contains()
+// method for that, but it sometimes behaves unexpectedly
+// because it selects the elements first and waits until
+// the existing items gets the specified text, instead of
+// waiting for an item with the right content.
+function selectItemByContent(selector, content) {
+	cy.log('Selecting item by content - start.');
+	cy.log('Param - selector: ' + selector);
+	cy.log('Param - content: ' + content);
+
+	// Wait for the content to appear
+	cy.get(selector)
+		.should('contain.text', content);
+
+	cy.log('Selecting item by content - end.');
+
+	// Select the right item (selector can point to more items)
+	return cy.get(selector).contains(content.replace('\u00a0', ' '));
+}
+
 module.exports.loadTestDoc = loadTestDoc;
 module.exports.assertCursorAndFocus = assertCursorAndFocus;
 module.exports.assertNoKeyboardInput = assertNoKeyboardInput;
@@ -163,3 +184,4 @@ module.exports.clearAllText = clearAllText;
 module.exports.getTextForClipboard = getTextForClipboard;
 module.exports.expectTextForClipboard = expectTextForClipboard;
 module.exports.afterAll = afterAll;
+module.exports.selectItemByContent = selectItemByContent;
diff --git a/cypress_test/integration_tests/common/mobile_helper.js b/cypress_test/integration_tests/common/mobile_helper.js
index f9e0b78f8..c63776596 100644
--- a/cypress_test/integration_tests/common/mobile_helper.js
+++ b/cypress_test/integration_tests/common/mobile_helper.js
@@ -34,8 +34,7 @@ function detectLOCoreVersion() {
 		openHamburgerMenu();
 
 		// Open about dialog
-		cy.get('.ui-header.level-0 .menu-entry-with-icon')
-			.contains('About')
+		helper.selectItemByContent('.ui-header.level-0 .menu-entry-with-icon', 'About')
 			.click();
 
 		cy.get('.vex-content')
@@ -172,12 +171,8 @@ function executeCopyFromContextMenu(XPos, YPos) {
 
 	longPressOnDocument(XPos, YPos);
 
-	cy.get('.menu-entry-with-icon')
-		.should('contain.text', 'Copy');
-
 	// Execute copy
-	cy.get('.menu-entry-with-icon')
-		.contains('Copy')
+	helper.selectItemByContent('.menu-entry-with-icon', 'Copy')
 		.click();
 
 	// Close warning about clipboard operations
diff --git a/cypress_test/integration_tests/desktop/copy_paste_spec.js b/cypress_test/integration_tests/desktop/copy_paste_spec.js
index a30111499..a4c2c3de5 100644
--- a/cypress_test/integration_tests/desktop/copy_paste_spec.js
+++ b/cypress_test/integration_tests/desktop/copy_paste_spec.js
@@ -26,14 +26,12 @@ describe('Clipboard operations.', function() {
 				cy.get('body').rightclick(XPos, YPos);
 			});
 
-		cy.get('.context-menu-list').should('be.visible')
-			.get('.context-menu-item .context-menu-link')
-			.contains('Copy')
+		helper.selectItemByContent('.context-menu-link', 'Copy')
 			.click();
 
 		// Loleaflet code can not execute document.execCommand() when executed by cypress
 		// https://github.com/cypress-io/cypress/issues/2851
 		cy.get('.vex-dialog-message p')
-			.contains('Your browser has very limited access to the clipboard, so use these keyboard shortcuts:');
+			.should('have.text', 'Your browser has very limited access to the clipboard, so use these keyboard shortcuts:');
 	});
 });
diff --git a/cypress_test/integration_tests/mobile/calc/apply_font_spec.js b/cypress_test/integration_tests/mobile/calc/apply_font_spec.js
index 1144e37b6..89a5fe2af 100644
--- a/cypress_test/integration_tests/mobile/calc/apply_font_spec.js
+++ b/cypress_test/integration_tests/mobile/calc/apply_font_spec.js
@@ -87,8 +87,7 @@ describe('Apply font changes.', function() {
 		cy.get('#fontnamecombobox')
 			.click();
 
-		cy.get('.mobile-wizard.ui-combobox-text')
-			.contains('Linux Libertine G')
+		helper.selectItemByContent('.mobile-wizard.ui-combobox-text', 'Linux Libertine G')
 			.click();
 
 		cy.get('.level-1[title="Font Name"] .mobile-wizard.ui-combobox-text.selected')
@@ -98,8 +97,8 @@ describe('Apply font changes.', function() {
 			.click();
 
 		// Combobox entry contains the selected font name
-		cy.get('#fontnamecombobox .ui-header-right')
-			.contains('Linux Libertine G');
+		cy.get('#fontnamecombobox .ui-header-right .entry-value')
+			.should('have.text', 'Linux Libertine G');
 
 		calcHelper.copyContentToClipboard();
 
@@ -112,8 +111,7 @@ describe('Apply font changes.', function() {
 		cy.get('#fontsizecombobox')
 			.click();
 
-		cy.get('.mobile-wizard.ui-combobox-text')
-			.contains('14')
+		helper.selectItemByContent('.mobile-wizard.ui-combobox-text', '14')
 			.click();
 
 		if (Cypress.env('LO_CORE_VERSION') === 'master')
@@ -127,8 +125,8 @@ describe('Apply font changes.', function() {
 			.click();
 
 		// Combobox entry contains the selected font name
-		cy.get('#fontsizecombobox .ui-header-right')
-			.contains('14');
+		cy.get('#fontsizecombobox .ui-header-right .entry-value')
+			.should('have.text', '14');
 
 		calcHelper.copyContentToClipboard();
 
diff --git a/cypress_test/integration_tests/mobile/calc/insertion_wizard_spec.js b/cypress_test/integration_tests/mobile/calc/insertion_wizard_spec.js
index 132949338..4dd1c3e60 100644
--- a/cypress_test/integration_tests/mobile/calc/insertion_wizard_spec.js
+++ b/cypress_test/integration_tests/mobile/calc/insertion_wizard_spec.js
@@ -28,16 +28,15 @@ describe('Calc insertion wizard.', function() {
 	});
 
 	it('Check existance of image insertion items.', function() {
-		cy.get('.menu-entry-with-icon')
-			.contains('Local Image...');
+		helper.selectItemByContent('.menu-entry-with-icon', 'Local Image...')
+			.should('be.visible');
 
-		cy.get('.menu-entry-with-icon')
-			.contains('Image...');
+		helper.selectItemByContent('.menu-entry-with-icon', 'Image...')
+			.should('be.visible');
 	});
 
 	it('Insert chart.', function() {
-		cy.get('.menu-entry-with-icon')
-			.contains('Chart...')
+		helper.selectItemByContent('.menu-entry-with-icon', 'Chart...')
 			.click();
 
 		cy.get('.leaflet-drag-transform-marker')
@@ -45,8 +44,7 @@ describe('Calc insertion wizard.', function() {
 	});
 
 	it('Insert hyperlink.', function() {
-		cy.get('.menu-entry-with-icon')
-			.contains('Hyperlink...')
+		helper.selectItemByContent('.menu-entry-with-icon', 'Hyperlink...')
 			.click();
 
 		// Dialog is opened
@@ -78,8 +76,7 @@ describe('Calc insertion wizard.', function() {
 
 	it('Insert shape.', function() {
 		// Do insertion
-		cy.get('.menu-entry-with-icon')
-			.contains('Shape')
+		helper.selectItemByContent('.menu-entry-with-icon', 'Shape')
 			.click();
 
 		cy.get('.basicshapes_ellipse').
@@ -98,8 +95,7 @@ describe('Calc insertion wizard.', function() {
 
 	it('Insert date.', function() {
 		// Do insertion
-		cy.get('.menu-entry-with-icon')
-			.contains('Date')
+		helper.selectItemByContent('.menu-entry-with-icon', 'Date')
 			.click();
 
 		calcHelper.copyContentToClipboard();
@@ -110,8 +106,7 @@ describe('Calc insertion wizard.', function() {
 
 	it('Insert time.', function() {
 		// Do insertion
-		cy.get('.menu-entry-with-icon')
-			.contains('Time')
+		helper.selectItemByContent('.menu-entry-with-icon', 'Time')
 			.click();
 
 		calcHelper.copyContentToClipboard();
diff --git a/cypress_test/integration_tests/mobile/calc/number_format_spec.js b/cypress_test/integration_tests/mobile/calc/number_format_spec.js
index e727ee56d..ae0243769 100644
--- a/cypress_test/integration_tests/mobile/calc/number_format_spec.js
+++ b/cypress_test/integration_tests/mobile/calc/number_format_spec.js
@@ -35,8 +35,7 @@ describe('Apply number formatting.', function() {
 		cy.get('#category')
 			.click();
 
-		cy.get('.mobile-wizard.ui-combobox-text')
-			.contains(formattingString)
+		helper.selectItemByContent('.mobile-wizard.ui-combobox-text', formattingString)
 			.click();
 
 		// Combobox entry contains the selected format
@@ -222,8 +221,7 @@ describe('Apply number formatting.', function() {
 		cy.get('#category')
 			.click();
 
-		cy.get('.mobile-wizard.ui-combobox-text')
-			.contains('Date')
+		helper.selectItemByContent('.mobile-wizard.ui-combobox-text', 'Date')
 			.click();
 
 		// Combobox entry contains the selected format
diff --git a/cypress_test/integration_tests/mobile/calc/spellchecking_spec.js b/cypress_test/integration_tests/mobile/calc/spellchecking_spec.js
index 24257d9ce..5fc7d95fa 100644
--- a/cypress_test/integration_tests/mobile/calc/spellchecking_spec.js
+++ b/cypress_test/integration_tests/mobile/calc/spellchecking_spec.js
@@ -55,8 +55,7 @@ describe('Calc spell checking menu.', function() {
 	it('Apply suggestion.', function() {
 		openContextMenu();
 
-		cy.get('.context-menu-link')
-			.contains('hello')
+		helper.selectItemByContent('.context-menu-link', 'hello')
 			.click();
 
 		// Click outside of the cell
@@ -81,8 +80,7 @@ describe('Calc spell checking menu.', function() {
 	it('Ignore all.', function() {
 		openContextMenu();
 
-		cy.get('.context-menu-link')
-			.contains('Ignore All')
+		helper.selectItemByContent('.context-menu-link', 'Ignore\u00a0All')
 			.click();
 
 		// Click outside of the cell
@@ -98,15 +96,14 @@ describe('Calc spell checking menu.', function() {
 		openContextMenu();
 
 		// We don't get the spell check context menu any more
-		cy.get('.context-menu-link')
-			.contains('Paste');
+		helper.selectItemByContent('.context-menu-link', 'Paste')
+			.should('be.visible');
 	});
 
 	it('Apply language for word.', function() {
 		openContextMenu();
 
-		cy.get('.context-menu-link')
-			.contains('Word is Finnish')
+		helper.selectItemByContent('.context-menu-link', 'Word\u00a0is Finnish')
 			.click();
 
 		// Click outside of the cell
@@ -122,15 +119,14 @@ describe('Calc spell checking menu.', function() {
 		openContextMenu();
 
 		// We don't get the spell check context menu any more
-		cy.get('.context-menu-link')
-			.contains('Paste');
+		helper.selectItemByContent('.context-menu-link', 'Paste')
+			.should('be.visible');
 	});
 
 	it('Apply language for paragraph.', function() {
 		openContextMenu();
 
-		cy.get('.context-menu-link')
-			.contains('Paragraph is Finnish')
+		helper.selectItemByContent('.context-menu-link', 'Paragraph\u00a0is Finnish')
 			.click();
 
 		// Click outside of the cell
@@ -146,7 +142,7 @@ describe('Calc spell checking menu.', function() {
 		openContextMenu();
 
 		// We don't get the spell check context menu any more
-		cy.get('.context-menu-link')
-			.contains('Paste');
+		helper.selectItemByContent('.context-menu-link', 'Paste')
+			.should('be.visible');
 	});
 });
diff --git a/cypress_test/integration_tests/mobile/impress/spellchecking_spec.js b/cypress_test/integration_tests/mobile/impress/spellchecking_spec.js
index c14193292..b85a8c350 100644
--- a/cypress_test/integration_tests/mobile/impress/spellchecking_spec.js
+++ b/cypress_test/integration_tests/mobile/impress/spellchecking_spec.js
@@ -63,8 +63,7 @@ describe('Spell checking menu.', function() {
 	it('Apply suggestion.', function() {
 		openContextMenu();
 
-		cy.get('.context-menu-link')
-			.contains('hello')
+		helper.selectItemByContent('.context-menu-link', 'hello')
 			.click();
 
 		impressHelper.copyShapeContentToClipboard();
@@ -79,42 +78,39 @@ describe('Spell checking menu.', function() {
 	it('Ignore all.', function() {
 		openContextMenu();
 
-		cy.get('.context-menu-link')
-			.contains('Ignore All')
+		helper.selectItemByContent('.context-menu-link', 'Ignore\u00a0All')
 			.click();
 
 		openContextMenu();
 
 		// We don't get the spell check context menu any more
-		cy.get('.context-menu-link')
-			.contains('Paste');
+		helper.selectItemByContent('.context-menu-link', 'Paste')
+			.should('be.visible');
 	});
 
 	it('Apply language for word.', function() {
 		openContextMenu();
 
-		cy.get('.context-menu-link')
-			.contains('Word is Finnish')
+		helper.selectItemByContent('.context-menu-link', 'Word\u00a0is Finnish')
 			.click();
 
 		openContextMenu();
 
 		// We don't get the spell check context menu any more
-		cy.get('.context-menu-link')
-			.contains('Paste');
+		helper.selectItemByContent('.context-menu-link', 'Paste')
+			.should('be.visible');
 	});
 
 	it('Apply language for paragraph.', function() {
 		openContextMenu();
 
-		cy.get('.context-menu-link')
-			.contains('Paragraph is Finnish')
+		helper.selectItemByContent('.context-menu-link', 'Paragraph\u00a0is Finnish')
 			.click();
 
 		openContextMenu();
 
 		// We don't get the spell check context menu any more
-		cy.get('.context-menu-link')
-			.contains('Paste');
+		helper.selectItemByContent('.context-menu-link', 'Paste')
+			.should('be.visible');
 	});
 });
diff --git a/cypress_test/integration_tests/mobile/writer/apply_font_spec.js b/cypress_test/integration_tests/mobile/writer/apply_font_spec.js
index f139cfa40..e16626b77 100644
--- a/cypress_test/integration_tests/mobile/writer/apply_font_spec.js
+++ b/cypress_test/integration_tests/mobile/writer/apply_font_spec.js
@@ -34,14 +34,13 @@ describe('Apply font changes.', function() {
 		cy.get('#mobile-wizard-back')
 			.should('be.visible');
 
-		cy.get('.mobile-wizard.ui-combobox-text')
-			.contains(styleName)
+		helper.selectItemByContent('.mobile-wizard.ui-combobox-text', styleName)
 			.click();
 
 		// Combobox entry contains the selected font name
 		if (styleName !== 'Clear formatting') {
 			cy.get('#applystyle .ui-header-right .entry-value')
-				.contains(styleName);
+				.should('have.text', styleName);
 		}
 
 		mobileHelper.closeMobileWizard();
@@ -52,8 +51,7 @@ describe('Apply font changes.', function() {
 		cy.get('#fontnamecombobox')
 			.click();
 
-		cy.get('.mobile-wizard.ui-combobox-text')
-			.contains('Linux Libertine G')
+		helper.selectItemByContent('.mobile-wizard.ui-combobox-text', 'Linux Libertine G')
 			.click();
 
 		cy.get('.level-1[title="Font Name"] .mobile-wizard.ui-combobox-text.selected')
@@ -63,8 +61,8 @@ describe('Apply font changes.', function() {
 			.click();
 
 		// Combobox entry contains the selected font name
-		cy.get('#fontnamecombobox .ui-header-right')
-			.contains('Linux Libertine G');
+		cy.get('#fontnamecombobox .ui-header-right .entry-value')
+			.should('have.text', 'Linux Libertine G');
 
 		writerHelper.copyTextToClipboard();
 
@@ -77,8 +75,7 @@ describe('Apply font changes.', function() {
 		cy.get('#fontsizecombobox')
 			.click();
 
-		cy.get('.mobile-wizard.ui-combobox-text')
-			.contains('36')
+		helper.selectItemByContent('.mobile-wizard.ui-combobox-text', '36')
 			.click();
 
 		if (Cypress.env('LO_CORE_VERSION') === 'master')
@@ -92,8 +89,8 @@ describe('Apply font changes.', function() {
 			.click();
 
 		// Combobox entry contains the selected font name
-		cy.get('#fontsizecombobox .ui-header-right')
-			.contains('36');
+		cy.get('#fontsizecombobox .ui-header-right .entry-value')
+			.should('have.text', '36');
 
 		writerHelper.copyTextToClipboard();
 
diff --git a/cypress_test/integration_tests/mobile/writer/focus_spec.js b/cypress_test/integration_tests/mobile/writer/focus_spec.js
index a8558763e..3a90e0f7d 100644
--- a/cypress_test/integration_tests/mobile/writer/focus_spec.js
+++ b/cypress_test/integration_tests/mobile/writer/focus_spec.js
@@ -45,7 +45,8 @@ describe('Focus tests', function() {
 			.should('be.eq', 'loleaflet-annotation-textarea');
 
 		// Close the dialog
-		cy.contains('Cancel').click();
+		cy.get('.vex-dialog-button-secondary')
+			.click();
 		cy.get('.loleaflet-annotation-table').should('be.not.visible');
 
 		// Body should have the focus again (no focus on document)
@@ -115,13 +116,12 @@ describe('Focus tests', function() {
 			.should('not.be.empty');
 
 		// Select More Fields
-		cy.get('.ui-header.level-0.mobile-wizard.ui-widget')
-			.contains('More Fields...')
-			.parent().click();
+		helper.selectItemByContent('.ui-header.level-0.mobile-wizard.ui-widget', 'More Fields...')
+			.click();
 
 		// Insert a field
-		cy.get('.ui-header.level-1.mobile-wizard.ui-widget .menu-entry-with-icon')
-			.contains('Page Number').click();
+		helper.selectItemByContent('.menu-entry-with-icon', 'Page Number')
+			.click();
 
 		cy.get('#mobile-wizard')
 			.should('not.be.visible');
@@ -143,8 +143,7 @@ describe('Focus tests', function() {
 			.should('not.be.empty');
 
 		// Do insertion
-		cy.get('.menu-entry-with-icon')
-			.contains('Shape')
+		helper.selectItemByContent('.menu-entry-with-icon', 'Shape')
 			.click();
 
 		cy.get('.col.w2ui-icon.basicshapes_rectangle').
diff --git a/cypress_test/integration_tests/mobile/writer/insert_field_spec.js b/cypress_test/integration_tests/mobile/writer/insert_field_spec.js
index c924b7e43..8bfba8fc8 100644
--- a/cypress_test/integration_tests/mobile/writer/insert_field_spec.js
+++ b/cypress_test/integration_tests/mobile/writer/insert_field_spec.js
@@ -18,8 +18,7 @@ describe('Insert fields via insertion wizard.', function() {
 			.should('be.visible');
 
 		// Open fields submenu
-		cy.get('.menu-entry-with-icon.flex-fullwidth')
-			.contains('More Fields...')
+		helper.selectItemByContent('.menu-entry-with-icon.flex-fullwidth', 'More Fields...')
 			.click();
 
 		cy.get('.ui-content.level-0.mobile-wizard')
@@ -32,34 +31,31 @@ describe('Insert fields via insertion wizard.', function() {
 
 	it('Insert page number field.', function() {
 		// Insert field
-		cy.get('.menu-entry-with-icon')
-			.contains('Page Number')
+		helper.selectItemByContent('.menu-entry-with-icon', 'Page Number')
 			.click();
 
 		writerHelper.copyTextToClipboard();
 
 		cy.get('#copy-paste-container p span sdfield')
 			.should('have.attr', 'type', 'PAGE')
-			.contains('1');
+			.should('have.text', '1');
 	});
 
 	it('Insert page count field.', function() {
 		// Insert field
-		cy.get('.menu-entry-with-icon')
-			.contains('Page Count')
+		helper.selectItemByContent('.menu-entry-with-icon', 'Page Count')
 			.click();
 
 		writerHelper.copyTextToClipboard();
 
 		cy.get('#copy-paste-container p span sdfield')
 			.should('have.attr', 'type', 'DOCSTAT')
-			.contains('1');
+			.should('have.text', '1');
 	});
 
 	it('Insert date field.', function() {
 		// Insert field
-		cy.get('.menu-entry-with-icon')
-			.contains('Date')
+		helper.selectItemByContent('.menu-entry-with-icon', 'Date')
 			.click();
 
 		writerHelper.copyTextToClipboard();
@@ -71,8 +67,7 @@ describe('Insert fields via insertion wizard.', function() {
 
 	it('Insert time field.', function() {
 		// Insert field
-		cy.get('.menu-entry-with-icon')
-			.contains('Time')
+		helper.selectItemByContent('.menu-entry-with-icon', 'Time')
 			.click();
 
 		writerHelper.copyTextToClipboard();
@@ -84,8 +79,7 @@ describe('Insert fields via insertion wizard.', function() {
 
 	it('Insert title field.', function() {
 		// Insert field
-		cy.get('.menu-entry-with-icon')
-			.contains('Title')
+		helper.selectItemByContent('.menu-entry-with-icon', 'Title')
 			.click();
 
 		writerHelper.copyTextToClipboard();
@@ -97,8 +91,7 @@ describe('Insert fields via insertion wizard.', function() {
 
 	it('Insert author field.', function() {
 		// Insert field
-		cy.get('.menu-entry-with-icon')
-			.contains('First Author')
+		helper.selectItemByContent('.menu-entry-with-icon', 'First Author')
 			.click();
 
 		writerHelper.copyTextToClipboard();
@@ -111,8 +104,7 @@ describe('Insert fields via insertion wizard.', function() {
 
 	it('Insert subject field.', function() {
 		// Insert field
-		cy.get('.menu-entry-with-icon')
-			.contains('Subject')
+		helper.selectItemByContent('.menu-entry-with-icon', 'Subject')
 			.click();
 
 		writerHelper.copyTextToClipboard();
diff --git a/cypress_test/integration_tests/mobile/writer/insert_formatting_mark_spec.js b/cypress_test/integration_tests/mobile/writer/insert_formatting_mark_spec.js
index 07a600d44..dc55069ce 100644
--- a/cypress_test/integration_tests/mobile/writer/insert_formatting_mark_spec.js
+++ b/cypress_test/integration_tests/mobile/writer/insert_formatting_mark_spec.js
@@ -18,8 +18,7 @@ describe('Insert formatting mark via insertion wizard.', function() {
 			.should('be.visible');
 
 		// Open formatting marks
-		cy.get('.menu-entry-with-icon.flex-fullwidth')
-			.contains('Formatting Mark')
+		helper.selectItemByContent('.menu-entry-with-icon.flex-fullwidth', 'Formatting Mark')
 			.click();
 
 		cy.get('.ui-content.level-0.mobile-wizard')
@@ -31,8 +30,7 @@ describe('Insert formatting mark via insertion wizard.', function() {
 	});
 
 	it('Insert non-breaking space.', function() {
-		cy.get('.menu-entry-with-icon')
-			.contains('Non-breaking space')
+		helper.selectItemByContent('.menu-entry-with-icon', 'Non-breaking space')
 			.click();
 
 		writerHelper.copyTextToClipboard();
@@ -45,8 +43,7 @@ describe('Insert formatting mark via insertion wizard.', function() {
 	});
 
 	it('Insert non-breaking hyphen.', function() {
-		cy.get('.menu-entry-with-icon')
-			.contains('Non-breaking hyphen')
+		helper.selectItemByContent('.menu-entry-with-icon', 'Non-breaking hyphen')
 			.click();
 
 		writerHelper.copyTextToClipboard();
@@ -59,8 +56,7 @@ describe('Insert formatting mark via insertion wizard.', function() {
 	});
 
 	it('Insert soft hyphen.', function() {
-		cy.get('.menu-entry-with-icon')
-			.contains('Soft hyphen')
+		helper.selectItemByContent('.menu-entry-with-icon', 'Soft hyphen')
 			.click();
 
 		writerHelper.copyTextToClipboard();
@@ -73,8 +69,7 @@ describe('Insert formatting mark via insertion wizard.', function() {
 	});
 
 	it('Insert no-width optional break.', function() {
-		cy.get('.menu-entry-with-icon')
-			.contains('No-width optional break')
+		helper.selectItemByContent('.menu-entry-with-icon', 'No-width optional break')
 			.click();
 
 		writerHelper.copyTextToClipboard();
@@ -87,8 +82,7 @@ describe('Insert formatting mark via insertion wizard.', function() {
 	});
 
 	it('Insert no-width no break.', function() {
-		cy.get('.menu-entry-with-icon')
-			.contains('No-width no break')
+		helper.selectItemByContent('.menu-entry-with-icon', 'No-width no break')
 			.click();
 
 		writerHelper.copyTextToClipboard();
@@ -101,8 +95,7 @@ describe('Insert formatting mark via insertion wizard.', function() {
 	});
 
 	it('Insert left-to-right mark.', function() {
-		cy.get('.menu-entry-with-icon')
-			.contains('Left-to-right mark')
+		helper.selectItemByContent('.menu-entry-with-icon', 'Left-to-right mark')
 			.click();
 
 		writerHelper.copyTextToClipboard();
@@ -115,8 +108,7 @@ describe('Insert formatting mark via insertion wizard.', function() {
 	});
 
 	it('Insert right-to-left mark.', function() {
-		cy.get('.menu-entry-with-icon')
-			.contains('Right-to-left mark')
+		helper.selectItemByContent('.menu-entry-with-icon', 'Right-to-left mark')
 			.click();
 
 		writerHelper.copyTextToClipboard();
diff --git a/cypress_test/integration_tests/mobile/writer/insert_object_spec.js b/cypress_test/integration_tests/mobile/writer/insert_object_spec.js
index 338230b44..b7d103e8e 100644
--- a/cypress_test/integration_tests/mobile/writer/insert_object_spec.js
+++ b/cypress_test/integration_tests/mobile/writer/insert_object_spec.js
@@ -26,8 +26,8 @@ describe('Insert objects via insertion wizard.', function() {
 			.should('be.visible');
 
 		// We check whether the entry is there
-		cy.get('.menu-entry-with-icon')
-			.contains('Local Image...');
+		helper.selectItemByContent('.menu-entry-with-icon', 'Local Image...')
+			.should('be.visible');
 		// We not not test the insertion, it might depend on the system.
 	});
 
@@ -38,8 +38,7 @@ describe('Insert objects via insertion wizard.', function() {
 		cy.get('#mobile-wizard')
 			.should('be.visible');
 
-		cy.get('.menu-entry-with-icon')
-			.contains('Comment')
+		helper.selectItemByContent('.menu-entry-with-icon', 'Comment')
 			.click();
 
 		// Comment insertion dialog is opened
@@ -72,9 +71,9 @@ describe('Insert objects via insertion wizard.', function() {
 			.should('be.visible');
 
 		// Open Table submenu
-		cy.get('.ui-header.level-0.mobile-wizard.ui-widget')
-			.contains('Table')
+		helper.selectItemByContent('.ui-header.level-0.mobile-wizard.ui-widget', 'Table')
 			.click();
+
 		cy.get('.mobile-wizard.ui-text')
 			.should('be.visible');
 
@@ -109,8 +108,7 @@ describe('Insert objects via insertion wizard.', function() {
 			.should('be.visible');
 
 		// Open Table submenu
-		cy.get('.ui-header.level-0.mobile-wizard.ui-widget')
-			.contains('Table')
+		helper.selectItemByContent('.ui-header.level-0.mobile-wizard.ui-widget', 'Table')
 			.click();
 		cy.get('.mobile-wizard.ui-text')
 			.should('be.visible');
@@ -158,20 +156,17 @@ describe('Insert objects via insertion wizard.', function() {
 			.should('be.visible');
 
 		// Open header/footer submenu
-		cy.get('.menu-entry-with-icon')
-			.contains('Header and Footer')
+		helper.selectItemByContent('.menu-entry-with-icon', 'Header and Footer')
 			.click();
 		cy.get('.ui-header.level-1.mobile-wizard.ui-widget')
 			.should('be.visible');
 
 		// Open header submenu
-		cy.get('.ui-header.level-1.mobile-wizard.ui-widget')
-			.contains('Header')
+		helper.selectItemByContent('.ui-header.level-1.mobile-wizard.ui-widget', 'Header')
 			.click();
 
 		// Insert header for All
-		cy.get('.menu-entry-no-icon')
-			.contains('All')
+		helper.selectItemByContent('.menu-entry-no-icon', 'All')
 			.click();
 
 		// Check that the cursor was moved
@@ -201,20 +196,17 @@ describe('Insert objects via insertion wizard.', function() {
 			.should('be.visible');
 
 		// Open header/footer submenu
-		cy.get('.menu-entry-with-icon')
-			.contains('Header and Footer')
+		helper.selectItemByContent('.menu-entry-with-icon', 'Header and Footer')
 			.click();
 		cy.get('.ui-header.level-1.mobile-wizard.ui-widget')
 			.should('be.visible');
 
 		// Open footer submenu
-		cy.get('.ui-header.level-1.mobile-wizard.ui-widget')
-			.contains('Footer')
+		helper.selectItemByContent('.ui-header.level-1.mobile-wizard.ui-widget', 'Footer')
 			.click();
 
 		// Insert footer for All
-		cy.get('.ui-content.level-1.mobile-wizard[title~="Footer"] .ui-header.level-2.mobile-wizard.ui-widget .menu-entry-no-icon')
-			.contains('All')
+		helper.selectItemByContent('.ui-content.level-1.mobile-wizard[title~="Footer"] .ui-header.level-2.mobile-wizard.ui-widget .menu-entry-no-icon', 'All')
 			.click();
 
 		// Check that the cursor was moved
@@ -244,8 +236,7 @@ describe('Insert objects via insertion wizard.', function() {
 			.should('be.visible');
 
 		// Insert footnote
-		cy.get('.menu-entry-with-icon')
-			.contains('Footnote')
+		helper.selectItemByContent('.menu-entry-with-icon', 'Footnote')
 			.click();
 
 		// Check that the cursor was moved
@@ -275,8 +266,7 @@ describe('Insert objects via insertion wizard.', function() {
 			.should('be.visible');
 
 		// Insert endnote
-		cy.get('.menu-entry-with-icon')
-			.contains('Endnote')
+		helper.selectItemByContent('.menu-entry-with-icon', 'Endnote')
 			.click();
 
 		// Check that the cursor was moved
@@ -305,9 +295,8 @@ describe('Insert objects via insertion wizard.', function() {
 		cy.get('#mobile-wizard')
 			.should('be.visible');
 
-		// Insert endnote
-		cy.get('.menu-entry-with-icon')
-			.contains('Page Break')
+		// Insert page break
+		helper.selectItemByContent('.menu-entry-with-icon', 'Page Break')
 			.click();
 
 		// Check that the cursor was moved
@@ -337,8 +326,7 @@ describe('Insert objects via insertion wizard.', function() {
 			.should('be.visible');
 
 		// Do insertion
-		cy.get('.menu-entry-with-icon')
-			.contains('Column Break')
+		helper.selectItemByContent('.menu-entry-with-icon', 'Column Break')
 			.click();
 
 		// Check that the cursor was moved
@@ -359,8 +347,7 @@ describe('Insert objects via insertion wizard.', function() {
 			.should('be.visible');
 
 		// Open hyperlink dialog
-		cy.get('.menu-entry-with-icon')
-			.contains('Hyperlink...')
+		helper.selectItemByContent('.menu-entry-with-icon', 'Hyperlink...')
 			.click();
 
 		// Dialog is opened
@@ -380,7 +367,7 @@ describe('Insert objects via insertion wizard.', function() {
 		writerHelper.copyTextToClipboard();
 
 		cy.get('#copy-paste-container p')
-			.contains('some text');
+			.should('have.text', '\nsome text');
 
 		cy.get('#copy-paste-container p a')
 			.should('have.attr', 'href', 'http://www.something.com/');
@@ -394,8 +381,7 @@ describe('Insert objects via insertion wizard.', function() {
 			.should('be.visible');
 
 		// Do insertion
-		cy.get('.menu-entry-with-icon')
-			.contains('Shape')
+		helper.selectItemByContent('.menu-entry-with-icon', 'Shape')
 			.click();
 
 		cy.get('.col.w2ui-icon.basicshapes_rectangle').
diff --git a/cypress_test/integration_tests/mobile/writer/mobile_wizard_state_spec.js b/cypress_test/integration_tests/mobile/writer/mobile_wizard_state_spec.js
index 741ce3e47..9b7ec28fc 100644
--- a/cypress_test/integration_tests/mobile/writer/mobile_wizard_state_spec.js
+++ b/cypress_test/integration_tests/mobile/writer/mobile_wizard_state_spec.js
@@ -34,8 +34,8 @@ describe('Mobile wizard state tests', function() {
 		// Open hamburger menu
 		mobileHelper.openHamburgerMenu();
 
-		cy.get('.ui-header.level-0.mobile-wizard.ui-widget .menu-entry-with-icon')
-			.contains('About');
+		helper.selectItemByContent('.ui-header.level-0.mobile-wizard.ui-widget .menu-entry-with-icon', 'About')
+			.should('be.visible');
 
 		// Close hamburger menu
 		mobileHelper.closeHamburgerMenu();
@@ -53,8 +53,8 @@ describe('Mobile wizard state tests', function() {
 		// Open context wizard by right click on document
 		mobileHelper.longPressOnDocument(40, 40);
 
-		cy.get('.ui-header.level-0.mobile-wizard.ui-widget .menu-entry-with-icon')
-			.contains('Paste');
+		helper.selectItemByContent('.ui-header.level-0.mobile-wizard.ui-widget .menu-entry-with-icon', 'Paste')
+			.should('be.visible');
 
 		// TODO: fix this bug
 		//cy.get('#tb_actionbar_item_mobile_wizard table')
diff --git a/cypress_test/integration_tests/mobile/writer/shape_properties_spec.js b/cypress_test/integration_tests/mobile/writer/shape_properties_spec.js
index 7b744bea6..5695d293e 100644
--- a/cypress_test/integration_tests/mobile/writer/shape_properties_spec.js
+++ b/cypress_test/integration_tests/mobile/writer/shape_properties_spec.js
@@ -28,8 +28,7 @@ describe('Change shape properties via mobile wizard.', function() {
 			.should('be.visible');
 
 		// Do insertion
-		cy.get('.menu-entry-with-icon')
-			.contains('Shape')
+		helper.selectItemByContent('.menu-entry-with-icon', 'Shape')
 			.click();
 
 		cy.get('.basicshapes_right-triangle').
@@ -230,8 +229,7 @@ describe('Change shape properties via mobile wizard.', function() {
 		cy.get('#linestyle')
 			.click();
 
-		cy.get('.ui-combobox-text')
-			.contains('Dashed')
+		helper.selectItemByContent('.ui-combobox-text', 'Dashed')
 			.click();
 
 		triggerNewSVG();
diff --git a/cypress_test/integration_tests/mobile/writer/spellchecking_spec.js b/cypress_test/integration_tests/mobile/writer/spellchecking_spec.js
index 8ac815018..0ea024302 100644
--- a/cypress_test/integration_tests/mobile/writer/spellchecking_spec.js
+++ b/cypress_test/integration_tests/mobile/writer/spellchecking_spec.js
@@ -50,8 +50,7 @@ describe('Spell checking menu.', function() {
 	it('Apply suggestion.', function() {
 		openContextMenu();
 
-		cy.get('.context-menu-link')
-			.contains('hello')
+		helper.selectItemByContent('.context-menu-link', 'hello')
 			.click();
 
 		writerHelper.copyTextToClipboard();
@@ -66,88 +65,79 @@ describe('Spell checking menu.', function() {
 	it('Ignore one.', function() {
 		openContextMenu();
 
-		cy.get('.context-menu-link')
-			.contains('Ignore')
+		helper.selectItemByContent('.context-menu-link', 'Ignore')
 			.click();
 
 		openContextMenu();
 
 		// We don't get the spell check context menu any more
-		cy.get('.context-menu-link')
-			.contains('Paste');
+		helper.selectItemByContent('.context-menu-link', 'Paste');
 	});
 
 	it('Ignore all.', function() {
 		openContextMenu();
 
-		cy.get('.context-menu-link')
-			.contains('Ignore All')
+		helper.selectItemByContent('.context-menu-link', 'Ignore\u00a0All')
 			.click();
 
 		openContextMenu();
 
 		// We don't get the spell check context menu any more
-		cy.get('.context-menu-link')
-			.contains('Paste');
+		helper.selectItemByContent('.context-menu-link', 'Paste')
+			.should('be.visible');
 	});
 
 	it('Check language status for selection.', function() {
 		openContextMenu();
 
-		cy.get('.menu-entry-with-icon')
-			.contains('Set Language for Selection')
+		helper.selectItemByContent('.menu-entry-with-icon', 'Set Language for Selection')
 			.click();
 
 		// English is selected
-		cy.get('.menu-entry-checked')
-			.contains('English (USA)');
+		helper.selectItemByContent('.ui-content[title="Set Language for Selection"] .menu-entry-checked', 'English\u00a0(USA)')
+			.should('be.visible');
 	});
 
 	it('Set None Language for selection.', function() {
 		openContextMenu();
 
-		cy.get('.menu-entry-with-icon')
-			.contains('Set Language for Selection')
+		helper.selectItemByContent('.menu-entry-with-icon', 'Set Language for Selection')
 			.click();
 
-		// English is selected
-		cy.get('.menu-entry-checked')
-			.contains('English (USA)');
+		helper.selectItemByContent('.ui-content[title="Set Language for Selection"] .menu-entry-with-icon', 'None\u00a0(Do not check spelling)')
+			.click();
 
 		openContextMenu();
 
 		// We don't get the spell check context menu any more
-		cy.get('.context-menu-link')
-			.contains('None (Do not check spelling)');
+		helper.selectItemByContent('.context-menu-link', 'Paste')
+			.should('be.visible');
 	});
 
 	it('Check language status for paragraph.', function() {
 		openContextMenu();
 
-		cy.get('.menu-entry-with-icon')
-			.contains('Set Language for Paragraph')
+		helper.selectItemByContent('.menu-entry-with-icon', 'Set Language for Paragraph')
 			.click();
 
 		// English is selected
-		cy.get('.menu-entry-checked')
-			.contains('English (USA)');
+		helper.selectItemByContent('.ui-content[title="Set Language for Paragraph"] .menu-entry-checked', 'English\u00a0(USA)')
+			.should('be.visible');
 	});
 
 	it('Set None Language for paragraph.', function() {
 		openContextMenu();
 
-		cy.get('.menu-entry-with-icon')
-			.contains('Set Language for Paragraph')
+		helper.selectItemByContent('.menu-entry-with-icon', 'Set Language for Paragraph')
 			.click();
 
-		// English is selected
-		cy.get('.menu-entry-checked')
-			.contains('English (USA)');
+		helper.selectItemByContent('.ui-content[title="Set Language for Paragraph"] .menu-entry-with-icon', 'None\u00a0(Do not check spelling)')
+			.click();
 
 		openContextMenu();
 
 		// We don't get the spell check context menu any more
-		cy.get('.context-menu-link')
-			.contains('None (Do not check spelling)');
+		helper.selectItemByContent('.context-menu-link', 'Paste')
+			.should('be.visible');
 	});
 });
diff --git a/cypress_test/integration_tests/mobile/writer/toolbar_spec.js b/cypress_test/integration_tests/mobile/writer/toolbar_spec.js
index 4453abcf7..a71f84c17 100644
--- a/cypress_test/integration_tests/mobile/writer/toolbar_spec.js
+++ b/cypress_test/integration_tests/mobile/writer/toolbar_spec.js
@@ -177,7 +177,7 @@ describe('Toolbar tests', function() {
 			.should('be.visible');
 
 		// Close the dialog
-		cy.contains('Cancel')
+		cy.get('.vex-dialog-button-secondary')
 			.click();
 
 		cy.get('.loleaflet-annotation-table')
diff --git a/cypress_test/integration_tests/mobile/writer/writer_helper.js b/cypress_test/integration_tests/mobile/writer/writer_helper.js
index 6bed4eb38..4a9c0382d 100644
--- a/cypress_test/integration_tests/mobile/writer/writer_helper.js
+++ b/cypress_test/integration_tests/mobile/writer/writer_helper.js
@@ -1,6 +1,7 @@
 /* global cy expect require*/
 
 var mobileHelper = require('../../common/mobile_helper');
+var helper = require('../../common/helper');
 
 function copyTextToClipboard() {
 	cy.log('Copying text to clipboard - start.');
@@ -57,20 +58,13 @@ function selectAllMobile() {
 
 	// Open hamburger menu
 	mobileHelper.openHamburgerMenu();
-	cy.get('#mobile-wizard')
-		.should('be.visible', {timeout : 10000});
 
 	// Open edit menu
-	cy.get('.ui-header.level-0 .menu-entry-with-icon')
-		.contains('Edit')
+	helper.selectItemByContent('.ui-header.level-0 .menu-entry-with-icon', 'Edit')
 		.click();
 
-	cy.get('.ui-header.level-1 .menu-entry-with-icon')
-		.should('be.visible');
-
 	// Do the selection
-	cy.get('.ui-header.level-1 .menu-entry-with-icon')
-		.contains('Select All')
+	helper.selectItemByContent('.ui-header.level-1 .menu-entry-with-icon', 'Select All')
 		.click();
 	cy.get('.leaflet-marker-icon')
 		.should('exist');


More information about the Libreoffice-commits mailing list