@@ -251,6 +251,8 @@ public void testDeleteUndeleteAttachment() throws IOException
251251 String wikiContent = "Lorem Ipsum something" ;
252252 String fileName = "wiki_temp_file_attachment.txt" ;
253253 File testAttachment = TestFileUtils .writeTempFile (fileName , "it was a dark and stormy night" );
254+ Locator wikiPageLinkLoc = Locator .linkWithText (wikiTitle );
255+ Locator editLinkLoc = Locator .linkWithText ("Edit" );
254256 Locator .XPathLocator attachmentParentLoc = Locator .id ("wiki-ea-name-0" );
255257 Locator .XPathLocator removeLinkLoc = Locator .tag ("td" ).child (Locator .linkContainingText ("remove" ));
256258 Locator .XPathLocator deleteLinkLoc = Locator .tag ("td" ).child (Locator .linkContainingText ("delete" ));
@@ -268,9 +270,10 @@ public void testDeleteUndeleteAttachment() throws IOException
268270 wikiHelper .setWikiBody ("<p>" + wikiContent + "</p>" );
269271 wikiHelper .saveWikiPage ();
270272 numberOfWikiCreated ++;
273+ clickAndWait (wikiPageLinkLoc );
271274
272275 log ("adding an attachment" );
273- wikiHelper . editWikiPage ( );
276+ clickAndWait ( editLinkLoc );
274277 click (filePickerLinkLoc );
275278 setFormElement (fileInputLoc , testAttachment );
276279 waitForElement (removeLinkLoc ); // when just attached, 'remove' will be an option but delete will not be
@@ -281,24 +284,27 @@ public void testDeleteUndeleteAttachment() throws IOException
281284 setFormElement (fileInputLoc , testAttachment );
282285 wikiHelper .saveWikiPage (); // save with the attachment
283286 waitForElement (Locator .linkWithText (fileName ));
287+ clickAndWait (wikiPageLinkLoc );
284288
285289 log ("Deleting attachment" );
286- wikiHelper . editWikiPage ( );
290+ clickAndWait ( editLinkLoc );
287291 click (deleteLinkLoc );
288292 waitForElement (attachmentParentLoc .withAttributeContaining ("style" , "text-decoration: line-through" ));
289293 wikiHelper .saveWikiPage ();
290294 // verify save while in deleted state actually deletes the attachment
291295 assertElementNotPresent (Locator .linkWithText (fileName ));
296+ clickAndWait (wikiPageLinkLoc );
292297
293298 log ("prepare to delete/undelete attachment" );
294299 // re-attach the file and save
295- wikiHelper . editWikiPage ( );
300+ clickAndWait ( editLinkLoc );
296301 click (filePickerLinkLoc );
297302 setFormElement (fileInputLoc , testAttachment );
298303 wikiHelper .saveWikiPage ();
304+ clickAndWait (wikiPageLinkLoc );
299305
300306 log ("Un-Deleting attachment" );
301- wikiHelper . editWikiPage ( );
307+ clickAndWait ( editLinkLoc );
302308 click (deleteLinkLoc ); // delete
303309 waitForElement (attachmentParentLoc .withAttributeContaining ("style" , "text-decoration: line-through" ));
304310 waitAndClick (undeleteLinkLoc );
0 commit comments