<div dir="ltr"><br><div>Jeff has done a great job with this.  He and I met in person today to make some improvements. We are very close to checking it in, but we encountered some anomalous behavior having to do with login and edit credentials among various users and various wikis, beta labs, test2wiki, and local environments.  Until we figure out what's causing that behavior we're not quite ready to push this out completely. </div>
<div><br></div><div>However, it does do the right thing, and the architecture is sound.  WARNING: if your user does not login to the target wiki properly, let us know at <a href="https://bugzilla.wikimedia.org/show_bug.cgi?id=60407">https://bugzilla.wikimedia.org/show_bug.cgi?id=60407</a></div>
<div><br></div><div>You can play with it by reviewing <a href="https://gerrit.wikimedia.org/r/#/c/106548/">https://gerrit.wikimedia.org/r/#/c/106548/</a></div><div><div><br></div><div>SCENARIOS</div><div><br></div><div>In your foo.feature file, you can now specify in a Scenario:</div>
<div><br></div><div>   Given I create a wiki page with title MY TEST WIKI PAGE and with content STUFF MY TEST EXPECTS TO FIND IN THE PAGE</div><div><br></div><div>and it will Just Work.  </div><div><br></div><div>* If the page does not exist in the target wiki, it will be created.</div>
<div>* If the page exists in the target wiki *with the same content*, it will *not* be updated. </div><div>* If the content specified in the foo.feature file is different than the existing wiki page, the page will be updated, the update will show correctly in Recent Changes, View History, etc. </div>
<div>* Your test will not proceed until the target wiki acknowledges the transaction, so tests should be safe from race conditions. </div><div><br></div><div>STEPS</div><div><br></div><div>The step that implements creating a wiki page invokes a method create_wiki_article that accepts four arguments to be passed to the Mediawiki API in order to create an article:</div>
<div><br></div><div>  create_wiki_article(ENV["MEDIAWIKI_USER"], ENV["MEDIAWIKI_PASSWORD"], api_title, api_content)</div><div><br></div><div>SUPPORT</div><div><br></div><div>Note that there is no foo.page file associated with an API call.  (The API is not a page, has no page elements, etc., so need for a PageObject file to invoke it.)  </div>
<div><br></div><div>Instead the create_wiki_article code is kept in a file /support/article.rb.  We use require_relative in the steps file for access to the article API call. Ultimately this will reside in the mediawiki/selenium Ruby gem.  </div>
<div><br></div><div>CREATING AN ARTICLE FROM A TEST</div><div><br></div><div>In order to create an article from a test, the following environment variables are required: </div><div><br></div><div>MEDIAWIKI_USER (standard)</div>
<div>MEDIAWIKI_PASSWORD (standard)</div><div>MEDIAWIKI_URL (standard)</div><div>API_URL (new: usually of the form <a href="http://test2.wikipedia.org/w/api.php">http://test2.wikipedia.org/w/api.php</a></div><div><br></div>
<div>and the page is created with the following data: </div><div><br></div><div>Title set in the .feature file</div><div>Page set in the .feature file</div><div>Summary is hard coded as "Article created via an API 'edit' call."</div>
<div>A category is added to each page [[Category:Browsertest article]] for future reference.</div><div><br></div><div>RANDOM VALUES FOR TITLE AND CONTENT</div><div><br></div><div>If random values are required for a test, we recommend manipulating those in the .steps file and passing those values to create_wiki_article in the .steps file. </div>
<div><br></div></div></div>