How to use getOuterHTML method in Playwright Internal

Best JavaScript code snippet using playwright-internal

Run Playwright Internal automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

link.js

Source: link.js Github

copy
1/* bender-tags: tableselection, link */
2/* bender-ckeditor-plugins: link,tableselection */
3/* bender-include: ../../_helpers/tableselection.js */
4/* global tableSelectionHelpers */
5
6( function() {
7	'use strict';
8
9	bender.editor = {
10		config: {
11			autoParagraph: false
12		}
13	};
14
15	function fixHtml( html ) {
16		html = html.replace( /\t/g, '' );
17
18		return bender.tools.fixHtml( html );
19	}
20
21	var getRangesForCells = tableSelectionHelpers.getRangesForCells,
22		table = CKEDITOR.document.getById( 'table' ).findOne( 'table' ),
23		editedLinkedTable = CKEDITOR.document.getById( 'table-with-link-edited' ).findOne( 'table' ),
24		multiLinkedTable = CKEDITOR.document.getById( 'table-with-links' ).findOne( 'table' ),
25		editedMultiLinkedTable = CKEDITOR.document.getById( 'table-with-links-edited' ).findOne( 'table' ),
26		anchoredTable = CKEDITOR.document.getById( 'table-with-anchor' ).findOne( 'table' ),
27		multiAnchoredTable = CKEDITOR.document.getById( 'table-with-anchors' ).findOne( 'table' ),
28		editedAnchoredTable = CKEDITOR.document.getById( 'table-with-anchors-edited' ).findOne( 'table' ),
29		removedAnchoredTable = CKEDITOR.document.getById( 'table-with-anchors-removed' ).findOne( 'table' );
30
31	var tests = {
32		'test create link': function() {
33			var editor = this.editor,
34				bot = this.editorBot,
35				ranges;
36
37			bot.setData( table.getOuterHtml(), function() {
38				ranges = getRangesForCells( editor, [ 1 ] );
39
40				editor.getSelection().selectRanges( ranges );
41
42				bot.dialog( 'link', function( dialog ) {
43					var displayTextField = dialog.getContentElement( 'info', 'linkDisplayText' )
44						.getElement().getParent().getParent();
45
46					assert.isTrue( displayTextField.isVisible(), '"Display Text" field visibility' );
47
48					dialog.setValueOf( 'info', 'url', 'cksource.com' );
49					dialog.getButton( 'ok' ).click();
50
51					assert.beautified.html( editedLinkedTable.getOuterHtml(), bot.getData() );
52				} );
53			} );
54		},
55
56		'test create link on multiple cells': function() {
57			var editor = this.editor,
58				bot = this.editorBot,
59				ranges;
60
61			bot.setData( table.getOuterHtml(), function() {
62				ranges = getRangesForCells( editor, [ 1, 2 ] );
63
64				editor.getSelection().selectRanges( ranges );
65
66				bot.dialog( 'link', function( dialog ) {
67					var displayTextField = dialog.getContentElement( 'info', 'linkDisplayText' )
68						.getElement().getParent().getParent();
69
70					assert.isFalse( displayTextField.isVisible(), '"Display Text" field is hidden' );
71
72					dialog.setValueOf( 'info', 'url', 'ckeditor.com' );
73					dialog.getButton( 'ok' ).click();
74
75					assert.areEqual( fixHtml( multiLinkedTable.getOuterHtml() ), bot.getData( true ) );
76				} );
77			} );
78		},
79
80		'test edit link (text selected)': function() {
81			var editor = this.editor,
82				bot = this.editorBot,
83				ranges;
84
85			bot.setData( multiLinkedTable.getOuterHtml(), function() {
86				ranges = getRangesForCells( editor, [ 1, 2 ] );
87
88				editor.getSelection().selectRanges( ranges );
89
90				bot.dialog( 'link', function( dialog ) {
91					var displayTextField = dialog.getContentElement( 'info', 'linkDisplayText' )
92						.getElement().getParent().getParent();
93
94					assert.isFalse( displayTextField.isVisible(), '"Display Text" field is hidden' );
95
96					dialog.setValueOf( 'info', 'url', 'http://cksource.com' );
97					dialog.getButton( 'ok' ).click();
98
99					assert.areSame( fixHtml( editedMultiLinkedTable.getOuterHtml() ), bot.getData( true ) );
100				} );
101			} );
102		},
103
104		// #tp2245
105		'test get link info from the cell with <br> filler': function() {
106			var editor = this.editor,
107				bot = this.editorBot,
108				protocol = 'https://',
109				url = 'cksource.com',
110				ranges;
111
112			bot.setData( CKEDITOR.document.getById( 'table-with-br' ).getOuterHtml(), function() {
113				ranges = getRangesForCells( editor, [ 0 ] );
114				editor.getSelection().selectRanges( ranges );
115
116				bot.dialog( 'link', function( dialog ) {
117					assert.areSame( url, dialog.getValueOf( 'info', 'url' ), 'Correct URL is set.' );
118					assert.areSame( protocol, dialog.getValueOf( 'info', 'protocol' ), 'Correct protocol is set.' );
119
120					dialog.getButton( 'ok' ).click();
121				} );
122			} );
123		},
124
125		'test unlink command': function() {
126			var editor = this.editor,
127				unlink = editor.getCommand( 'unlink' ),
128				bot = this.editorBot,
129				ranges;
130
131			bot.setData( multiLinkedTable.getOuterHtml(), function() {
132				ranges = getRangesForCells( editor, [ 1, 2 ] );
133
134				editor.getSelection().selectRanges( ranges );
135				assert.isTrue( unlink.state == CKEDITOR.TRISTATE_OFF, 'unlink is enabled' );
136
137				editor.execCommand( 'unlink' );
138				assert.areSame( fixHtml( table.getOuterHtml() ), bot.getData( true ), 'links are removed' );
139			} );
140		},
141
142		'test getSelectedLink for table selection (links)': function() {
143			var editor = this.editor,
144				bot = this.editorBot,
145				ranges,
146				links,
147				selectedLinks,
148				i;
149
150			bot.setData( multiLinkedTable.getOuterHtml(), function() {
151				links = editor.editable().find( 'a' );
152				ranges = getRangesForCells( editor, [ 1, 2 ] );
153
154				editor.getSelection().selectRanges( ranges );
155				selectedLinks = CKEDITOR.plugins.link.getSelectedLink( editor, true );
156
157				assert.areSame( links.count(), selectedLinks.length, 'All links found' );
158
159				for ( i = 0; i < links.count(); i++ ) {
160					assert.isTrue( links.getItem( i ).equals( selectedLinks[ i ] ),
161						'The correct links is selected' );
162				}
163			} );
164		},
165
166		'test create anchor': function() {
167			var editor = this.editor,
168				bot = this.editorBot,
169				ranges;
170
171			bot.setData( table.getOuterHtml(), function() {
172				ranges = getRangesForCells( editor, [ 1, 2 ] );
173
174				editor.getSelection().selectRanges( ranges );
175
176				bot.dialog( 'anchor', function( dialog ) {
177					dialog.setValueOf( 'info', 'txtName', 'foo' );
178					dialog.getButton( 'ok' ).click();
179
180					assert.areEqual( fixHtml( anchoredTable.getOuterHtml() ), bot.getData( true ) );
181				} );
182			} );
183		},
184
185		'test edit anchor (text selected)': function() {
186			var editor = this.editor,
187				bot = this.editorBot,
188				ranges;
189
190			bot.setData( multiAnchoredTable.getOuterHtml(), function() {
191				ranges = getRangesForCells( editor, [ 1, 2 ] );
192
193				editor.getSelection().selectRanges( ranges );
194
195				bot.dialog( 'anchor', function( dialog ) {
196					dialog.setValueOf( 'info', 'txtName', 'baz' );
197					dialog.getButton( 'ok' ).click();
198
199					assert.areSame( fixHtml( editedAnchoredTable.getOuterHtml() ), bot.getData( true ) );
200				} );
201			} );
202		},
203
204		'test removeAnchor command': function() {
205			var editor = this.editor,
206				unlink = editor.getCommand( 'removeAnchor' ),
207				bot = this.editorBot,
208				ranges;
209
210			bot.setData( multiAnchoredTable.getOuterHtml(), function() {
211				ranges = getRangesForCells( editor, [ 1, 2 ] );
212
213				editor.getSelection().selectRanges( ranges );
214				assert.isTrue( unlink.state == CKEDITOR.TRISTATE_OFF, 'removeAnchor is enabled' );
215
216				editor.execCommand( 'removeAnchor' );
217				assert.areSame( fixHtml( removedAnchoredTable.getOuterHtml() ), bot.getData( true ),
218					'anchors are removed' );
219			} );
220		},
221
222		'test getSelectedLink for table selection (anchors)': function() {
223			var editor = this.editor,
224				bot = this.editorBot,
225				ranges,
226				links,
227				selectedLinks,
228				i;
229
230			bot.setData( anchoredTable.getOuterHtml(), function() {
231				links = editor.editable().find( 'a' );
232				ranges = getRangesForCells( editor, [ 1, 2 ] );
233
234				editor.getSelection().selectRanges( ranges );
235				selectedLinks = CKEDITOR.plugins.link.getSelectedLink( editor, true );
236
237				assert.areSame( links.count(), selectedLinks.length, 'All links found' );
238
239				for ( i = 0; i < links.count(); i++ ) {
240					assert.isTrue( links.getItem( i ).equals( selectedLinks[ i ] ),
241						'The correct links is selected' );
242				}
243			} );
244		}
245	};
246
247	tableSelectionHelpers.ignoreUnsupportedEnvironment( tests );
248
249	bender.test( tests );
250} )();
251
Full Screen

no-get-inner-outer-html.js

Source: no-get-inner-outer-html.js Github

copy
1'use strict'
2
3var rule = require('../../lib/rules/no-get-inner-outer-html')
4var RuleTester = require('eslint').RuleTester
5
6var eslintTester = new RuleTester()
7
8eslintTester.run('no-get-inner-outer-html', rule, {
9  valid: [
10    'expect(element(by.id("myid")).getText()).toEqual("test");',
11    'getInnerHtml();',
12    'var html = getOuterHtml();',
13    'elm.getInnerHtml();',
14    'elm.getOuterHtml();'
15  ],
16
17  invalid: [
18    {
19      code: 'expect(element(by.id("myid")).getInnerHtml()).toEqual("test");',
20      errors: [
21        {
22          message: 'Unexpected "getInnerHtml()"'
23        }
24      ]
25    },
26    {
27      code: 'expect(element(by.id("myid")).getOuterHtml()).toEqual("test");',
28      errors: [
29        {
30          message: 'Unexpected "getOuterHtml()"'
31        }
32      ]
33    },
34    {
35      code: 'element.all(by.css(".class")).get(1).getOuterHtml();',
36      errors: [
37        {
38          message: 'Unexpected "getOuterHtml()"'
39        }
40      ]
41    },
42    {
43      code: 'element.all(by.css(".class")).first().getOuterHtml();',
44      errors: [
45        {
46          message: 'Unexpected "getOuterHtml()"'
47        }
48      ]
49    },
50    {
51      code: 'element(by.id("id")).all(by.css(".class")).last().getInnerHtml();',
52      errors: [
53        {
54          message: 'Unexpected "getInnerHtml()"'
55        }
56      ]
57    },
58    {
59      code: '$$(".class").first().getOuterHtml();',
60      errors: [
61        {
62          message: 'Unexpected "getOuterHtml()"'
63        }
64      ]
65    },
66    {
67      code: '$(".class").getInnerHtml().then(function (html) { console.log(html) });',
68      errors: [
69        {
70          message: 'Unexpected "getInnerHtml()"'
71        }
72      ]
73    }
74  ]
75})
76
Full Screen

Accelerate Your Automation Test Cycles With LambdaTest

Leverage LambdaTest’s cloud-based platform to execute your automation tests in parallel and trim down your test execution time significantly. Your first 100 automation testing minutes are on us.

Try LambdaTest

Run JavaScript Tests on LambdaTest Cloud Grid

Execute automation tests with Playwright Internal on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free
LambdaTestX

We use cookies to give you the best experience. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. Learn More in our Cookies policy, Privacy & Terms of service

Allow Cookie
Sarah

I hope you find the best code examples for your project.

If you want to accelerate automated browser testing, try LambdaTest. Your first 100 automation testing minutes are FREE.

Sarah Elson (Product & Growth Lead)