mediawiki-extensions-Cite/tests/selenium/pageobjects/cite.page.js
vidhi-mody 76c38c766d Selenium: Update to WebdriverIO v5
Update NPM packages: webdriverio, wdio-mediawiki.

Replace NPM packages:
- wdio-mocha-framework with @wdio/mocha-framework.
- wdio-spec-reporter with @wdio/spec-reporter.

New NPM packages: @wdio/cli, @wdio/local-runner, @wdio/sync.

Replace:
- `browser.element` with `$`.
- `browser.elements` with `$$`.
- `chromeOptions` with `'goog:chromeOptions'`.
- `password` with `mwPwd`.
- `username` with `mwUser`.
- `waitForVisible()` with `waitForDisplayed()`.
- `isVisible()` with `isDisplayed()`.

Bug: T253343
Change-Id: Ia656c8bc9fa76ae80bc356dc18c821a93b8cd875
2020-06-25 01:19:38 +05:30

24 lines
856 B
JavaScript

'use strict';
const Page = require( 'wdio-mediawiki/Page' ),
Util = require( 'wdio-mediawiki/Util' );
class CitePage extends Page {
getReference( num ) { return $$( '#mw-content-text .reference' )[ num - 1 ]; }
getCiteMultiBacklink( num ) { return $( '.references li:nth-of-type(' + num + ') .mw-cite-up-arrow-backlink' ); }
getCiteSingleBacklink( num ) { return $( '.references li:nth-of-type(' + num + ') .mw-cite-backlink a' ); }
getCiteSubBacklink( num ) { return $( '.mw-cite-backlink sup:nth-of-type(' + num + ') a' ); }
scriptsReady() {
Util.waitForModuleState( 'ext.cite.ux-enhancements' );
}
getFragmentFromLink( linkElement ) {
// the href includes the full url so slice the fragment from it
const href = linkElement.getAttribute( 'href' );
return href.slice( href.indexOf( '#' ) + 1 );
}
}
module.exports = new CitePage();