getUtil().createPage(sourceSpaceName, sourcePageName, PAGE_CONTENT, sourcePageName);
// Add an attachment to verify that it's version is not incremented in the target document (XWIKI-8157).
// FIXME: Remove the following wait when XWIKI-6688 is fixed.
viewPage.waitForDocExtraPaneActive("comments");
AttachmentsPane attachmentsPane = viewPage.openAttachmentsDocExtraPane();
attachmentsPane.setFileToUpload(getClass().getResource("/image.gif").getPath());
attachmentsPane.waitForUploadToFinish("image.gif");
Assert.assertEquals("1.1", attachmentsPane.getLatestVersionOfAttachment("image.gif"));
// Click on Copy from the Page top menu.
CopyPage copyPage = viewPage.copy();
// Check form content
Assert.assertEquals(sourceSpaceName, copyPage.getSourceSpaceName());
Assert.assertEquals(sourcePageName, copyPage.getSourcePageName());
Assert.assertEquals(sourceSpaceName, copyPage.getTargetSpaceName());
Assert.assertEquals(sourcePageName, copyPage.getTargetPageName());
// Fill the target destination the page to be copied to.
copyPage.setTargetSpaceName(targetSpaceName);
copyPage.setTargetPageName(targetPageName);
// Click copy button
CopyConfirmationPage copyConfirmationPage = copyPage.clickCopyButton();
// Check successful copy confirmation
Assert.assertTrue(copyConfirmationPage.getInfoMessage().contains(COPY_SUCCESSFUL));
viewPage = copyConfirmationPage.goToNewPage();
// Verify that the copied title is modified to be the new page name since it was set to be the page name
// originally.
Assert.assertEquals(targetPageName, viewPage.getDocumentTitle());
Assert.assertEquals(PAGE_CONTENT, viewPage.getContent());
// Verify the attachment version is the same (XWIKI-8157).
// FIXME: Remove the following wait when XWIKI-6688 is fixed.
viewPage.waitForDocExtraPaneActive("comments");
attachmentsPane = viewPage.openAttachmentsDocExtraPane();
Assert.assertEquals("1.1", attachmentsPane.getLatestVersionOfAttachment("image.gif"));
}