-'use strict';
-const Page = require( './page' );
+const Page = require( 'wdio-mediawiki/Page' ),
+ Api = require( 'wdio-mediawiki/Api' );
class EditPage extends Page {
-
get content() { return browser.element( '#wpTextbox1' ); }
- get displayedContent() { return browser.element( '#mw-content-text' ); }
+ get conflictingContent() { return browser.element( '#wpTextbox2' ); }
+ get displayedContent() { return browser.element( '#mw-content-text .mw-parser-output' ); }
get heading() { return browser.element( '#firstHeading' ); }
get save() { return browser.element( '#wpSave' ); }
+ get previewButton() { return browser.element( '#wpPreview' ); }
+
+ openForEditing( title ) {
+ super.openTitle( title, { action: 'edit' } );
+ }
- openForEditing( name ) {
- super.open( name + '&action=edit' );
+ preview( name, content ) {
+ this.openForEditing( name );
+ this.content.setValue( content );
+ this.previewButton.click();
}
edit( name, content ) {
this.save.click();
}
+ // @deprecated Use wdio-mediawiki/Api#edit() instead.
apiEdit( name, content ) {
-
- const MWBot = require( 'mwbot' ), // https://github.com/Fannon/mwbot
- Promise = require( 'bluebird' );
- let bot = new MWBot();
-
- return Promise.coroutine( function* () {
- yield bot.loginGetEditToken( {
- apiUrl: `${browser.options.baseUrl}/api.php`,
- username: browser.options.username,
- password: browser.options.password
- } );
- yield bot.edit( name, content, `Created page with "${content}"` );
- } ).call( this );
-
+ return Api.edit( name, content );
}
-
}
+
module.exports = new EditPage();