auphong2707/dl4se-code-review-dataset huggingface dataset:
Source:
public void loginExistingAccount(String userName, String password) { waitForElementByElement(existingUsernameField); existingUsernameField.sendKeys(userName); PageObjectLogging.log("loginExistingAccount", "username " + userName + " typed into the field", true); waitForElementByElement(existingPasswordField); existingPasswordField.sendKeys(password); PageObjectLogging.log("loginExistingAccount", "password " + password + " typed into the field", true); loginExistingButton.click(); START PageObjectLogging.log("loginExistingAccount", "login button clicked", true); END } We have global event listener which log each click, so you don't need to do it by yourself.

Target:
public void loginExistingAccount(String userName, String password) { waitForElementByElement(existingUsernameField); existingUsernameField.sendKeys(userName); PageObjectLogging.log("loginExistingAccount", "username " + userName + " typed into the field", true); waitForElementByElement(existingPasswordField); existingPasswordField.sendKeys(password); PageObjectLogging.log("loginExistingAccount", "password " + password + " typed into the field", true); loginExistingButton.click(); }
Source:
public void waitForDialogVisible() { waitForElementByElement(dialog); START waitForElementVisibleByElement(dialog); END } Those two methods are similar. Consider using one.

Target:
public void waitForDialogVisible() { waitForElementVisibleByElement(dialog); }
Source:
public VisualEditorSaveChangesDialog clickReturnToSaveFormButton() { waitForElementClickableByElement(returnToSaveFormButton); returnToSaveFormButton.click(); PageObjectLogging START .log("clickReturnToSaveFormButton", "Return To Save Form button clicked", true); END return new VisualEditorSaveChangesDialog(driver); } Global listener catch each click. You don't need to log it.

Target:
public VisualEditorSaveChangesDialog clickReturnToSaveFormButton() { waitForElementClickableByElement(returnToSaveFormButton); returnToSaveFormButton.click(); return new VisualEditorSaveChangesDialog(driver); }
Source:
public VisualEditorSaveChangesDialog clickSaveWithRecaptcha() { waitForElementClickableByElement(publishButton); if (checkIfElementOnPage(recaptchaArea)) { recaptchaContainer = saveDialogBody.findElement(recaptchaImageBy); waitForElementVisibleByElement(recaptchaContainer); } publishButton.click(); START PageObjectLogging.log("clickSaveWithRecaptcha", "The 2nd Publish Button is clicked", true); END return new VisualEditorSaveChangesDialog(driver); } You are logging already logged click.

Target:
public VisualEditorSaveChangesDialog clickSaveWithRecaptcha() { waitForElementClickableByElement(publishButton); if (checkIfElementOnPage(recaptchaArea)) { recaptchaContainer = saveDialogBody.findElement(recaptchaImageBy); waitForElementVisibleByElement(recaptchaContainer); } publishButton.click(); return new VisualEditorSaveChangesDialog(driver); }
Source:
public VisualEditorReviewChangesDialog clickReviewYourChanges() { waitForElementVisibleByElement(reviewChangesButton); START waitForElementClickableByElement(reviewChangesButton); END reviewChangesButton.click(); PageObjectLogging.log("clickReviewYourChanges", "Review Your Changes Button is clicked", true); return new VisualEditorReviewChangesDialog(driver); } double wait

Target:
public VisualEditorReviewChangesDialog clickReviewYourChanges() { waitForElementVisibleByElement(reviewChangesButton); waitForElementClickableByElement(reviewChangesButton); reviewChangesButton.click(); return new VisualEditorReviewChangesDialog(driver); }
Source:
public void typeInEditArea(String text) { waitForDialogVisible(); waitForElementNotVisibleByElement(loadingIndicator); WebElement editArea = dialog.findElement(editAreaBy); waitForElementVisibleByElement(editArea); START waitForElementClickableByElement(editArea); END editArea.sendKeys(text); waitForValueToBePresentInElementsAttributeByElement(editArea, "value", text); PageObjectLogging.log("typeInEditArea", "Typed " + text, true, driver); } double wait

Target:
public void typeInEditArea(String text) { waitForDialogVisible(); waitForElementNotVisibleByElement(loadingIndicator); WebElement editArea = dialog.findElement(editAreaBy); waitForElementClickableByElement(editArea); editArea.sendKeys(text); waitForValueToBePresentInElementsAttributeByElement(editArea, "value", text); PageObjectLogging.log("typeInEditArea", "Typed " + text, true, driver); }
Source:
public void verifyOpeningArticleInNav(int anchorIndex) { waitForElementVisibleByElement(noChevrons.get(anchorIndex)); START if (noChevrons.size() != 0) { END noChevrons.get(anchorIndex).click(); PageObjectLogging.log("verifyOpeningArticleInNav", "New article opened", true, driver); } } is this check necessary since noChevrons.get(index) is already being called prior to this?

Target:
public void verifyOpeningArticleInNav(int anchorIndex) { waitForElementVisibleByElement(noChevrons.get(anchorIndex)); noChevrons.get(anchorIndex).click(); PageObjectLogging.log("verifyOpeningArticleInNav", "New article opened", true, driver); }
Source:
public void verifyBackLinkFunctionality(int anchorIndex) { waitForElementVisibleByElement(chevrons.get(anchorIndex)); START if (chevrons.size() != 0) { END chevrons.get(anchorIndex).click(); waitForElementVisibleByElement(backChevron); backChevron.click(); PageObjectLogging.log("verifyBackLinkFunctionality", "Back button is working", true, driver); } } is this check necessary since chevrons.get(index) is already being called prior to this?

Target:
public void verifyBackLinkFunctionality(int anchorIndex) { waitForElementVisibleByElement(chevrons.get(anchorIndex)); chevrons.get(anchorIndex).click(); waitForElementVisibleByElement(backChevron); backChevron.click(); PageObjectLogging.log("verifyBackLinkFunctionality", "Back button is working", true, driver); }
Source:
START private void showSlot(String selector, WebDriver driver) { END changeVisibility(selector, "visible", driver); } why is this private? and show slot is public?

Target:
public void showSlot(String selector, WebDriver driver) { changeVisibility(selector, "visible", driver); }
Source:
public VenusGlobalNavPageObject openHubsMenuViaHover() { Actions actions = new Actions(driver); actions.moveToElement(menuButton); actions.build().perform(); START WebDriverWait wait = new WebDriverWait(driver, 5); END wait.until(CommonExpectedConditions.elementVisible(hubsMenu)); return this; } no need to declare a avriable "wait" just ``` new WebdriverWait(driver, 5).until(...) .... ``` will do the job

Target:
public VenusGlobalNavPageObject openHubsMenuViaHover() { new Actions(driver) .moveToElement(menuButton) .perform(); new WebDriverWait(driver, 5).until(CommonExpectedConditions.elementVisible(hubsMenu)); return this; }
Source:
public void DeleteAndRestoreMapTests_004_StaffUserCanDeleteMap() { WikiBasePageObject base = new WikiBasePageObject(driver); base.logInCookie(credentials.userNameStaff, credentials.passwordStaff, wikiURL); START InteractiveMapPageObject selectedMap = base.openInteractiveMapById(wikiURL, InteractiveMapsContent.mapToDeleteAndRestore); END selectedMap.verifyMapOpened(); String deletedMapId = selectedMap.getEmbedMapID(); DeleteAMapComponentObject deleteMapModal = selectedMap.deleteMap(); InteractiveMapsPageObject specialMap = deleteMapModal.deleteMap(); specialMap.verifyMapDeletedMessage(); } Would suggest using another MapID for 004 and 005 to break dependency from 001 and 002 to be successful

Target:
public void DeleteAndRestoreMapTests_004_StaffUserCanDeleteMap() { WikiBasePageObject base = new WikiBasePageObject(driver); base.logInCookie(credentials.userNameStaff, credentials.passwordStaff, wikiURL); InteractiveMapPageObject selectedMap = base.openInteractiveMapById(wikiURL, InteractiveMapsContent.mapToDeleteAndRestore[2]); selectedMap.verifyMapOpened(); DeleteAMapComponentObject deleteMapModal = selectedMap.deleteMap(); InteractiveMapsPageObject specialMap = deleteMapModal.deleteMap(); }
Source:
public void DeleteAndRestoreMapTests_005_StaffUserCanRestoreMap() { WikiBasePageObject base = new WikiBasePageObject(driver); base.logInCookie(credentials.userNameStaff, credentials.passwordStaff, wikiURL); START InteractiveMapPageObject selectedMap = base.openInteractiveMapById(wikiURL, InteractiveMapsContent.mapToDeleteAndRestore); END selectedMap.verifyMapOpened(); selectedMap.verifyMapDeletedMsg(); selectedMap.restoreMap(); selectedMap.verifyMapDeletedMsgNotVisible(); } Would suggest using another MapID for 004 and 005 to break dependency from 001 and 002 to be successful

Target:
public void DeleteAndRestoreMapTests_005_StaffUserCanRestoreMap() { WikiBasePageObject base = new WikiBasePageObject(driver); base.logInCookie(credentials.userNameStaff, credentials.passwordStaff, wikiURL); InteractiveMapPageObject selectedMap = base.openInteractiveMapById(wikiURL, InteractiveMapsContent.mapToDeleteAndRestore[2]); selectedMap.verifyMapOpened(); selectedMap.restoreMap(); }
Source:
public void DeleteAndRestoreMapTests_006_SysOpCanDeleteMap() { WikiBasePageObject base = new WikiBasePageObject(driver); base.logInCookie(credentials.userNameSysop, credentials.passwordSysop, wikiURL); START InteractiveMapPageObject selectedMap = base.openInteractiveMapById(wikiURL, InteractiveMapsContent.mapToDeleteAndRestore); END selectedMap.verifyMapOpened(); String deletedMapId = selectedMap.getEmbedMapID(); DeleteAMapComponentObject deleteMapModal = selectedMap.deleteMap(); InteractiveMapsPageObject specialMap = deleteMapModal.deleteMap(); specialMap.verifyMapDeletedMessage(); } Would suggest using another MapID for 006 and 007 to break dependency from 001 and 002 to be successful

Target:
public void DeleteAndRestoreMapTests_006_SysOpCanDeleteMap() { WikiBasePageObject base = new WikiBasePageObject(driver); base.logInCookie(credentials.userNameSysop, credentials.passwordSysop, wikiURL); InteractiveMapPageObject selectedMap = base.openInteractiveMapById(wikiURL, InteractiveMapsContent.mapToDeleteAndRestore[3]); selectedMap.verifyMapOpened(); DeleteAMapComponentObject deleteMapModal = selectedMap.deleteMap(); InteractiveMapsPageObject specialMap = deleteMapModal.deleteMap(); }
Source:
public void DeleteAndRestoreMapTests_007_SysOpCanRestoreMap() { WikiBasePageObject base = new WikiBasePageObject(driver); base.logInCookie(credentials.userNameSysop, credentials.passwordSysop, wikiURL); START InteractiveMapPageObject selectedMap = base.openInteractiveMapById(wikiURL, InteractiveMapsContent.mapToDeleteAndRestore); END selectedMap.verifyMapOpened(); selectedMap.verifyMapDeletedMsg(); selectedMap.restoreMap(); selectedMap.verifyMapDeletedMsgNotVisible(); } Would suggest using another MapID for 006 and 007 to break dependency from 001 and 002 to be successful

Target:
public void DeleteAndRestoreMapTests_007_SysOpCanRestoreMap() { WikiBasePageObject base = new WikiBasePageObject(driver); base.logInCookie(credentials.userNameSysop, credentials.passwordSysop, wikiURL); InteractiveMapPageObject selectedMap = base.openInteractiveMapById(wikiURL, InteractiveMapsContent.mapToDeleteAndRestore[3]); selectedMap.verifyMapOpened(); selectedMap.restoreMap(); }
Source:
public int getNumberOfResultTemplates() { switchToIFrame(); START int numberOfTemplates = -1; END if (checkIfElementOnPage(resultTemplatesBy)) { numberOfTemplates = resultTemplates.size(); } else { numberOfTemplates = 0; } switchOutOfIFrame(); PageObjectLogging.log("getNumberOfResultTemplates", "Number of result templates found: " + numberOfTemplates, true); return numberOfTemplates; } Why are you assigning -1 to numberOfTemplates, if you assigning different value in the next line?

Target:
public int getNumberOfResultTemplates() { switchToIFrame(); try { if (resultTemplates.isEmpty()) { return 0; } else { return resultTemplates.size(); } } finally { PageObjectLogging.log( "getNumberOfResultTemplates", "Number of result templates found: " + resultTemplates.size(), true ); switchOutOfIFrame(); } }
Source:
public int getNumberOfResultTemplates() { switchToIFrame(); int numberOfTemplates = 0; if (checkIfElementOnPage(resultTemplatesBy)) { numberOfTemplates = resultTemplates.size(); } switchOutOfIFrame(); PageObjectLogging.log("getNumberOfResultTemplates", "Number of result templates found: " + numberOfTemplates, true); START return numberOfTemplates; END } method can look like this: ``` switchToIFrame(); try { if (resultTemplates.isEmpty()) { return 0; } else { return resultTemplates.size(); } } finally { PageObjectLogging.log("getNumberOfResultTemplates", "Number of result templates found: " + resultTemplates.size(), true); switchOutOfIFrame(); } ``` decide if this is more readable to you

Target:
public int getNumberOfResultTemplates() { switchToIFrame(); try { if (resultTemplates.isEmpty()) { return 0; } else { return resultTemplates.size(); } } finally { PageObjectLogging.log( "getNumberOfResultTemplates", "Number of result templates found: " + resultTemplates.size(), true ); switchOutOfIFrame(); } }
Source:
protected boolean checkIfElementOnPage(By cssSelectorBy) { changeImplicitWait(500, TimeUnit.MILLISECONDS); boolean isElementOnPage = true; try { if (driver.findElements(cssSelectorBy).size() < 1) { isElementOnPage = false; } START } catch (Exception ex) { END isElementOnPage = false; } finally { restoreDeaultImplicitWait(); } return isElementOnPage; } why catch all exception?

Target:
protected boolean checkIfElementOnPage(By cssSelectorBy) { changeImplicitWait(500, TimeUnit.MILLISECONDS); try { return driver.findElements(cssSelectorBy).size() > 0; } finally { restoreDeaultImplicitWait(); } }
Source:
public void verifyMonetizationModuleShown() { Assertion.assertTrue(checkIfElementOnPage(monetizationModuleContainer)); START PageObjectLogging.log("verifyMonetizationModuleShown", "Monetization module is shown", true); END waitForElementByElement(monetizationModuleContainer); PageObjectLogging.log("verifyMonetizationModuleShown", "Monetization module is visible", true); } is it necessary to log here? The assertion above would put logging into the file already. Also, I see that there's another logging at the end of the method

Target:
public void verifyMonetizationModuleShown() { Assertion.assertTrue(checkIfElementOnPage(monetizationModuleContainer)); waitForElementByElement(monetizationModuleContainer); PageObjectLogging.log("verifyMonetizationModuleShown", "Monetization module is visible", true); }
Source:
public void verifyMonetizationModuleAdsenseShown() { Assertion.assertTrue(checkIfElementOnPage(adsenseContainer)); Assertion.assertTrue(checkIfElementOnPage(adsenseIns)); START PageObjectLogging.log("verifyMonetizationModuleAdsenseShown", "Monetization module is shown (adsense)", true); END waitForElementByElement(adsenseContainer); PageObjectLogging.log("verifyMonetizationModuleAdsenseShown", "Monetization module is visible (adsense)", true); } s it necessary to log here? The assertion above would put logging into the file already. Also, I see that there's another logging at the end of the method

Target:
public void verifyMonetizationModuleAdsenseShown() { Assertion.assertTrue(checkIfElementOnPage(adsenseContainer)); Assertion.assertTrue(checkIfElementOnPage(adsenseIns)); waitForElementByElement(adsenseContainer); PageObjectLogging.log("verifyMonetizationModuleAdsenseShown", "Monetization module is visible (adsense)", true); }
Source:
public void setCookieGeo(String countryCode) { String cookieName = "Geo"; try { JSONObject geo = new JSONObject(); geo.put("country", countryCode); START String value = geo.toString(); END setCookie(cookieName, value); } catch (JSONException ex) { PageObjectLogging.log("setCookieGeo", "Cannot set cookie ('" + cookieName + "')", true); } } This variable is not necessary since you are only using it for the next line.

Target:
public void setCookieGeo(String countryCode) { String cookieName = "Geo"; try { JSONObject geo = new JSONObject(); geo.put("country", countryCode); setCookie(cookieName, geo.toString()); } catch (JSONException ex) { PageObjectLogging.log("setCookieGeo", "Cannot set cookie ('" + cookieName + "')", true); } }
Source:
public DeleteAMapComponentObject deleteMap() { waitForElementByElement(actionDropDown); START Actions actions = new Actions(driver); END actions .click(actionDropDown) .click(deleteMapButton) .build() .perform(); return new DeleteAMapComponentObject(driver); } Why is action object necessary here? Isn't it enough with clicking just the two desired elements below using click methods?

Target:
public DeleteAMapComponentObject deleteMap() { waitForElementByElement(actionDropDown); actionDropDown.click(); deleteMapButton.click(); return new DeleteAMapComponentObject(driver); }
Source:
public ArticlePageObject savePage() { switchToIFrame(); waitForElementInViewPort(editSummary); START WebElement publishButton = driver.findElement(By.cssSelector(".oo-ui-window-foot .oo-ui-flaggableElement-constructive .oo-ui-labeledElement-label")); END waitForElementClickableByElement(publishButton); //Temp work around - The dialog needs time to transition to the front try { Thread.sleep(1000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } publishButton.click(); PageObjectLogging.log("savePage", "The 2nd Publish Button is clicked", true); switchOutOfIFrame(); return new ArticlePageObject(driver); } please move 'By.cssSelector(".oo-ui-window-foot .oo-ui-flaggableElement-constructive .oo-ui-labeledElement-label")' on the top of class as By

Target:
public ArticlePageObject savePage() { switchToIFrame(); waitForElementInViewPort(editSummary); waitForElementClickableByElement(publishButton); publishButton.click(); PageObjectLogging.log("savePage", "The 2nd Publish Button is clicked", true); switchOutOfIFrame(); return new ArticlePageObject(driver); }
Source:
public void clickPublishButtonDropdown() { scrollAndClick(cssPublishButtonDropdown); PageObjectLogging.log("clickCssPublishButton", "click on publish button dropdown", true); START waitForElementByElement(cssPublishButtonDropdown); END } is there any reason that you wait for element after clicking it? if not please remove it from the method :)

Target:
public void clickPublishButtonDropdown() { scrollAndClick(cssPublishButtonDropdown); PageObjectLogging.log("clickCssPublishButton", "click on publish button dropdown", true); }
Source:
public String getEmbedMapWikiCode(){ String mapID = mapFrame.getAttribute("data-mapid"); String r = "<imap map-id='"+mapID+"'/>"; START return r; END } I believe you could just combine the two lines and just return "<imap map-id='"+mapID+"'/>";

Target:
public String getEmbedMapWikiCode() { return "<imap map-id='" + mapFrame.getAttribute("data-mapid") + "'/>"; }
Source:
public void verifyTemplateWasFound() { waitForElementVisibleByElement(templatesBox); waitForElementByElement(thumbCollection.get(0)); START System.out.println(thumbCollection.get(0)); END System.out.println(checkIfElementOnPage(thumbCollection.get(0))); Assertion.assertEquals(checkIfElementOnPage(thumbCollection.get(0)), true); } remove the console printout system.out.println

Target:
public void verifyTemplateWasFound() { waitForElementVisibleByElement(templatesBox); waitForElementByElement(thumbCollection.get(0)); Assertion.assertEquals(checkIfElementOnPage(thumbCollection.get(0)), true); }
Source:
public String getAssociatedArticleImageSrc() { waitForElementByElement(associatedArticleImage); String imageSrc = articleImageUrl.getAttribute("src"); START System.out.println(imageSrc); END return imageSrc; } remove system out print

Target:
public String getAssociatedArticleImageSrc() { waitForElementByElement(associatedArticleImage); return articleImageUrl.getAttribute("src"); }
Source:
public String getAssociatedArticleImageSrc() { waitForElementByElement(associatedArticleImage); String imageSrc = articleImageUrl.getAttribute("src"); START return imageSrc; END } Could return articleImageUrl.getAttribute("src"); in one line since imageSrc is not being used anywhere else.

Target:
public String getAssociatedArticleImageSrc() { waitForElementByElement(associatedArticleImage); return articleImageUrl.getAttribute("src"); }
Source:
public void typePinDescription(String pinDescription) { waitForElementByElement(descriptionField); descriptionField.sendKeys(pinDescription); START PageObjectLogging.log("typePinDescription", "Pin description was typed in", true); END } As I see that in the other method, the parameter is also in the log. Consider adding pinDescription into the log?

Target:
public void typePinDescription(String pinDescription) { waitForElementByElement(descriptionField); descriptionField.sendKeys(pinDescription); PageObjectLogging.log("typePinDescription", pinDescription + "Pin description was typed in", true); }
Source:
public void verifyAllPinTypesIsUncheck() { try { waitForElementVisibleByElement(mapFrame); driver.switchTo().frame(mapFrame); waitForElementVisibleByElement(allPinTypes); if (!allPinTypes.getAttribute("class").contains("enabled")) { PageObjectLogging.log("verifyAllPointTypesIsUnCheck", "All pin types were unchecked", true); } driver.switchTo().defaultContent(); }catch (Exception e) { START PageObjectLogging.log("verifyAllPointTypesIsUnCheck", "All pin types were checked", false); END } } log the error stack instead

Target:
public void verifyAllPinTypesIsUncheck() { waitForElementVisibleByElement(mapFrame); driver.switchTo().frame(mapFrame); waitForElementVisibleByElement(allPinTypes); if (!allPinTypes.getAttribute("class").contains("enabled")) { PageObjectLogging.log("verifyAllPointTypesIsUnCheck", "All pin types were unchecked", true); }else { PageObjectLogging.log("verifyAllPointTypesIsUnCheck", "All pin types were checked", false); } driver.switchTo().defaultContent(); }
Source:
public void verifyPinNotExist(String pinTitle) { START Integer pinSize = pinCollection.size() - 1; END while (pinSize >= 0) { if (pinCollection.get(pinSize).getText().contains(pinTitle)) { break; } pinSize--; } Assertion.assertEquals(pinSize.intValue(), -1, "Pin was deleted correctly"); } why is Integer needed here instead of int?

Target:
public void verifyPinNotExist(String pinTitle) { int pinSize = pinCollection.size() - 1; while (pinSize >= 0) { if (pinCollection.get(pinSize).getText().contains(pinTitle)) { break; } pinSize--; } Assertion.assertEquals(pinSize, -1, "Pin was deleted correctly"); }
Source:
public void verifyPinDataWasChanged(String pinName, String pinDesc) { waitForElementVisibleByElement(mapFrame); driver.switchTo().frame(mapFrame); waitForElementVisibleByElement(popUpContent); scrollToElement(popUpContent); waitForElementVisibleByElement(pinTitle); waitForElementVisibleByElement(pinDescription); String actualTitle = pinTitle.getText(); String actualDesc = pinDescription.getText(); START Assertion.assertNotEquals(pinName, actualTitle); END Assertion.assertNotEquals(pinDesc, actualDesc); } use pinTitle.getText(); and remove the variable that is being used once.

Target:
public void verifyPinDataWasChanged(String pinName, String pinDesc) { waitForElementVisibleByElement(mapFrame); driver.switchTo().frame(mapFrame); waitForElementVisibleByElement(popUpContent); scrollToElement(popUpContent); waitForElementVisibleByElement(pinTitle); waitForElementVisibleByElement(pinDescription); Assertion.assertNotEquals(pinName, pinTitle.getText()); Assertion.assertNotEquals(pinDesc, pinDescription.getText()); }
Source:
public String getMapLink(int mapIndex) { String mapLink = mapList.get(mapIndex).getAttribute("href"); START return mapLink; END } return in one line

Target:
public String getMapLink(int mapIndex) { return mapList.get(mapIndex).getAttribute("href"); }
Source:
public String getMapTitle(int mapIndex) { String mapTitle = mapTitleList.get(mapIndex).getText(); START return mapTitle; END } return in one line

Target:
public String getMapTitle(int mapIndex) { return mapTitleList.get(mapIndex).getText(); }
Source:
public File getUploadedImage() { waitForElementByElement(thumbnailImage); File uploadedImageFile = new File(PageContent.resourcesPath + "shouldBeDeleted.png"); try { URL url = new URL(thumbnailImage.getAttribute("src")); BufferedImage bufImgOne = ImageIO.read(url); ImageIO.write(bufImgOne, "png", uploadedImageFile); } catch (IOException e) { START e.printStackTrace(); END } return uploadedImageFile; } maybe instead of printing stack trace to console you can throw RuntimeException? It doesn't have to be declared and if something goes wrong you are notified about it in the right way - you don't need to look for the cause in logs

Target:
public File getUploadedImage() { waitForElementByElement(thumbnailImage); File uploadedImageFile = new File(PageContent.resourcesPath + "shouldBeDeleted.png"); try { URL url = new URL(thumbnailImage.getAttribute("src")); BufferedImage bufImgOne = ImageIO.read(url); ImageIO.write(bufImgOne, "png", uploadedImageFile); } catch (IOException e) { throw new RuntimeException(); } return uploadedImageFile; }
Source:
public void RTEDisabledEditorEntryDefaultPreferredTests_001_CreatePageEntry() { String articleName = PageContent.articleNamePrefix + base.getTimeStamp(); ArticlePageObject article = START base.openArticleByName(wikiURL, articleName); END VisualEditorPageObject ve = article.createArticleInVEUsingDropdown(articleName); ve.verifyVEToolBarPresent(); ve.verifyEditorSurfacePresent(); ve.logOut(wikiURL); } It'll fit in one line

Target:
public void RTEDisabledEditorEntryDefaultPreferredTests_001_CreatePageEntry() { String articleName = PageContent.articleNamePrefix + base.getTimeStamp(); ArticlePageObject article = base.openArticleByName(wikiURL, articleName); VisualEditorPageObject ve = article.createArticleInVEUsingDropdown(articleName); ve.verifyVEToolBarPresent(); ve.verifyEditorSurfacePresent(); }
Source:
public void verifyUndoSucceeded() { START driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); END waitForElementByElement(notification); String notificationMsg = notification.getText(); Assertion.assertEquals(notificationMsg, "This page has been restored."); PageObjectLogging.log("verifyUndoSucceeded", "able to undo a swapped video", true); } Please remove this line. It is not needed

Target:
public void verifyUndoSucceeded() { waitForElementByElement(notification); String notificationMsg = notification.getText(); Assertion.assertEquals(notificationMsg, "This page has been restored."); PageObjectLogging.log("verifyUndoSucceeded", "able to undo a swapped video", true); }
Source:
public void banUser(String userName, WebDriver driver) { clickBanUser(userName, driver); chatBanModalButton.click(); waitForElementNotVisibleByElement(chatBanModal); PageObjectLogging.log("clickBanUser", userName+" ban modal is closed", START true, driver); END } remove 'driver' parameter from log( ... ) method with "driver" parameter screenshot will be taken, thus test will execute longer, we possibly omit taking screnshoots, as it increases execution tmie

Target:
public void banUser(String userName, WebDriver driver) { clickBanUser(userName, driver); chatBanModalButton.click(); waitForElementNotVisibleByElement(chatBanModal); PageObjectLogging.log("clickBanUser", userName+" ban modal is closed", true); }
Source:
public void unBanUser(String userName, WebDriver driver) { WebElement unbanLink = driver.findElement(By.xpath( String.format(userUnbanLink, userName) )); waitForElementByElement(unbanLink); unbanLink.click(); verifyChatUnbanMessage(userName); PageObjectLogging.log("unBanUser", userName+" is no longer banned", START true, driver); END } remove 'driver' parameter from log( ... ) method

Target:
public void unBanUser(String userName, WebDriver driver) { WebElement unbanLink = driver.findElement(By.xpath( String.format(userUnbanLink, userName) )); waitForElementByElement(unbanLink); unbanLink.click(); verifyChatUnbanMessage(userName); PageObjectLogging.log("unBanUser", userName+" is no longer banned", true); }
Source:
START public String getLastEditHistoryDevice() { END return editHistoriesDevice.get(0).getText(); } change to private

Target:
private String getLastEditHistoryDevice() { return editHistoriesDevice.get(0).getText(); }
Source:
public void MobileLogin_002_failedLoginWrongPassword() { MobileBasePageObject mobile = new MobileBasePageObject(driver); mobile.openHome(wikiURL); mobile.openRandomPage(); START System.out.println(credentials.userName12); END MobileSpecialUserLogin login = mobile.loginFailedDropDown(credentials.userName12, mobile.getTimeStamp()); login.verifyWrongPasswordErrorMessage(); } remove this line

Target:
public void MobileLogin_002_failedLoginWrongPassword() { MobileBasePageObject mobile = new MobileBasePageObject(driver); mobile.openHome(wikiURL); mobile.openRandomPage(); MobileSpecialUserLogin login = mobile.loginFailedDropDown(credentials.userName12, mobile.getTimeStamp()); login.verifyWrongPasswordErrorMessage(); }
Source:
public void MobileLogin_004_failedLoginEmptyPassword_MOB_760() { MobileBasePageObject mobile = new MobileBasePageObject(driver); mobile.openHome(wikiURL); mobile.openRandomPage(); START System.out.println(credentials.userName12); END MobileSpecialUserLogin login = mobile.loginFailedDropDown(credentials.userName12, ""); login.verifyEmptyPasswordErrorMessage(); } remove this line

Target:
public void MobileLogin_004_failedLoginEmptyPassword_MOB_760() { MobileBasePageObject mobile = new MobileBasePageObject(driver); mobile.openHome(wikiURL); mobile.openRandomPage(); MobileSpecialUserLogin login = mobile.loginFailedDropDown(credentials.userName12, ""); login.verifyEmptyPasswordErrorMessage(); }
Source:
START public void appendNewLine(String content) { END waitForElementByElement(sourceModeTextArea); sourceModeTextArea.sendKeys(Keys.ENTER); sourceModeTextArea.sendKeys(content); PageObjectLogging.log("appendNewLine", "text "+content+" added to the source mode in new line", true); } This can be reverted back to being private

Target:
private void appendNewLine(String content) { waitForElementByElement(sourceModeTextArea); sourceModeTextArea.sendKeys(Keys.ENTER); sourceModeTextArea.sendKeys(content); PageObjectLogging.log("appendNewLine", "text "+content+" added to the source mode in new line", true); }
Source:
public String removeQueryStringsFromURL(String url) { if (url.contains("?")) { return url.substring(0, url.indexOf("?")); } START else return url; END } you can either remove else or add pair of curly brackets

Target:
public String removeQueryStringsFromURL(String url) { if (url.contains("?")) { return url.substring(0, url.indexOf("?")); } return url; }
Source:
public void verifyAddTableLightbox() { waitForElementByElement(addTableLightbox); START Assertion.assertTrue(lightboxBackground.getCssValue("background-color").equals(backgroundLigthboxColor)); END } why this assertion is necessary?

Target:
public void verifyAddTableLightbox() { waitForElementByElement(addTableLightbox); }
Source:
public TableBuilderComponentObject clickAddTableButton(){ START waitForElementClickableByElement(addTableButton); END addTableButton.click(); PageObjectLogging.log("addTable", "add table button clicked", true); return new TableBuilderComponentObject(driver); } you don't have to wait for it

Target:
public TableBuilderComponentObject clickAddTableButton(){ addTableButton.click(); PageObjectLogging.log("addTable", "add table button clicked", true); return new TableBuilderComponentObject(driver); }
Source:
public void addContent(String content) { sourceModeTextArea.sendKeys(content); START PageObjectLogging.log("addContent", "content was added", true, driver); END } remove driver, there is no need to capture screenshot after sending keys

Target:
public void addContent(String content) { sourceModeTextArea.sendKeys(content); PageObjectLogging.log("addContent", "content was added", true); }
Source:
public String getFirstDescription() { START waitForElementByElement(firstResult); END return firstResultDescription.getText(); } this element is load by ajax? you probably don't have to wait for an element here

Target:
public String getFirstDescription() { return firstResultDescription.getText(); }
Source:
public void verifyQuery(String query) { START boolean flag = false; END for (WebElement element:resultLinks) { if (element.getText().contains(query)){ flag=true; } } Assertion.assertTrue(flag, "there is no result link in the page"); } change flag to isPresent

Target:
public void verifyQuery(String query) { boolean isPresent = false; for (WebElement element:resultLinks) { if (element.getText().contains(query)){ isPresent = true; break; } } Assertion.assertTrue(isPresent, "there is no result link in the page"); }
Source:
public void switchAndQuoteMessageWall(String reply) { START driver.switchTo().defaultContent(); END driver.switchTo().frame(quoteMessageWallFrame); driver.findElement(By.cssSelector("body#bodyContent")).clear(); driver.findElement(By.cssSelector("body#bodyContent")).sendKeys(reply); PageObjectLogging.log("switchAndQuoteMessageWall", "quote typed", true); } remove this line

Target:
public void switchAndQuoteMessageWall(String reply) { driver.switchTo().frame(quoteMessageWallFrame); driver.findElement(By.cssSelector("body#bodyContent")).clear(); driver.findElement(By.cssSelector("body#bodyContent")).sendKeys(reply); PageObjectLogging.log("switchAndQuoteMessageWall", "quote typed", true); }
Source:
public NewMessageWallThreadPageObject openThread(String threadName) { for (WebElement thread:threadList) { if (thread.getText().contains(threadName)){ scrollAndClick(thread); } START break; END } return new NewMessageWallThreadPageObject(driver); } with break statement here the process will get outside of the "for" loop after the first round. So only one element of threadList will be considered...

Target:
public NewMessageWallThreadPageObject openThread(String threadName) { for (WebElement thread:threadList) { if (thread.getText().contains(threadName)){ scrollAndClick(thread); break; } } return new NewMessageWallThreadPageObject(driver); }
Source:
public void verifyInputExpand(String comment) { showCommentsSection(); String inputHeight = commentInputArea.getCssValue("height"); commentInputArea.sendKeys(comment); String inputExpandedHeight = commentInputArea.getCssValue("height"); START Assertion.assertTrue(Integer.parseInt(inputExpandedHeight.substring(0, 1)) END > Integer.parseInt(inputHeight.substring(0, 1)), "input is not bigger" ); } wrong formatting, hard to read

Target:
public void verifyInputExpand(String comment) { showCommentsSection(); int inputHeight = Integer.parseInt(commentInputArea.getCssValue("height").substring(0, 1)); commentInputArea.sendKeys(comment); int inputExpandedHeight = Integer.parseInt(commentInputArea.getCssValue("height").substring(0, 1)); Assertion.assertTrue(inputExpandedHeight > inputHeight, "input is not bigger"); }
Source:
public void verifySectionVisibility(){ waitForElementByElement(sectionVisibilityElement); START PageObjectLogging.log("verifySectionVisibility", "section is opened and visible", true, driver); END } I know its not your line, but please remove "driver" parameter. This parameter is not needed here, because screenshot is not needed in verification methods.

Target:
public void verifySectionVisibility(){ waitForElementByElement(sectionVisibilityElement); PageObjectLogging.log("verifySectionVisibility", "section is opened and visible", true); }
Source:
public void switchAndWrite(String text) { driver.switchTo().frame(miniEditorIframe); START waitForElementByElement(messageBodyField); END messageBodyField.sendKeys(text); } use writeMiniEditor() method instead of waitForElementByElement(messageBodyField); messageBodyField.sendKeys(text);

Target:
public void switchAndWrite(String text) { waitForElementByElement(miniEditorIframe); driver.switchTo().frame(miniEditorIframe); waitForElementByElement(messageBodyField); messageBodyField.sendKeys(text); }
Source:
public void SignUp_validation_1() { SignUpPageObject signUpPage = new SignUpPageObject(driver); signUpPage.openSignUpPage(); signUpPage.typeInUserName(signUpPage.getTimeStamp()); String userNameEmail = Properties.emailQaart4; START signUpPage.typeInEmail(userNameEmail); END signUpPage.typeInPassword(signUpPage.getTimeStamp()); signUpPage.enterBirthDate( PageContent.wikiSignUpBirthMonth, PageContent.wikiSignUpBirthDay, PageContent.wikiSignUpBirthYear ); signUpPage.enterWrongBlurryWord(); signUpPage.clickCreateAccountButton(); signUpPage.verifyWrongBlurryWordValidation(); } pass the Properties.emailQaart4 as argument / no need to create additional string

Target:
public void SignUp_validation_1() { SignUpPageObject signUpPage = new SignUpPageObject(driver); signUpPage.openSignUpPage(); signUpPage.typeInUserName(signUpPage.getTimeStamp()); signUpPage.typeInEmail(Properties.emailQaart4); signUpPage.typeInPassword(signUpPage.getTimeStamp()); signUpPage.enterBirthDate( PageContent.wikiSignUpBirthMonth, PageContent.wikiSignUpBirthDay, PageContent.wikiSignUpBirthYear ); signUpPage.enterWrongBlurryWord(); signUpPage.clickCreateAccountButton(); signUpPage.verifyWrongBlurryWordValidation(); }
Source:
public void typeInUserName(String userName) { userNameField.sendKeys(userName); userNameField.sendKeys(Keys.TAB); PageObjectLogging.log("typeInUserName ", "User name field populated " START +userName, true, driver); END } PageObjectLogging.log( "typeInUserName ", +"User name field populated " +userName, true, driver ); Remember about spaces between + and String, put trailing ")" in seperate line Remove the driver from PageObjectLogging (no need to take screenshot)

Target:
public void typeInUserName(String userName) { userNameField.sendKeys(userName); userNameField.sendKeys(Keys.TAB); PageObjectLogging.log( "typeInUserName ", "User name field populated " + userName, true ); }
Source:
public void waitForTooYoungErrorMsg() { waitForElementByElement(tooYoungError); Assertion.assertTrue(tooYoungError.isDisplayed()); START PageObjectLogging.log("typeInBirthDate ", "BirthDate field selected", true, driver); END } remove driver from PageObjectLogging (no need to take screenshot)

Target:
public void waitForTooYoungErrorMsg() { waitForElementByElement(tooYoungError); Assertion.assertTrue(tooYoungError.isDisplayed()); PageObjectLogging.log("typeInBirthDate ", "BirthDate field selected", true); }
Source:
public void enterBlurryWord() { String word = getWordFromCaptcha(); blurryWordField.sendKeys(word); START PageObjectLogging.log("enterBlurryWord ", "Blurry word field populated", true, driver); END } remove the driver

Target:
public void enterBlurryWord() { String word = getWordFromCaptcha(); blurryWordField.sendKeys(word); PageObjectLogging.log("enterBlurryWord ", "Blurry word field populated", true); }
Source:
START private void typeSearchQuery(String query) { END waitForElementByElement(searchField); searchField.sendKeys(query); } This method is used only in another method, why did you make this encapsulation?

Target:
public void typeSearchQuery(String query) { searchField.sendKeys(query); }
Source:
public void clickEdit() { clickAndWait(editLink); changeToMonoBook(); START PageObjectLogging.log("clickEdit", "click on Edit link", true, driver); END } driver

Target:
public void clickEdit() { clickAndWait(editLink); PageObjectLogging.log("clickEdit", "click on Edit link", true); }
Source:
public ComparisonExecutor(AliasResolver aliasResolver) { START asyncComparisonExecutor = newAsyncComparisonExecutor(); END this.aliasResolver = aliasResolver; } I would also use the two argument constructor here (keep the default visibility) and provide a factory method that creates the ComparisonExecutor with the "production" executor service.

Target:
public ComparisonExecutor(AliasResolver aliasResolver) { this(newAsyncComparisonExecutor(), aliasResolver); }
Source:
public ApplicationStatus getApplicationStatus() { START ApplicationStatus applicationStatus = new ApplicationStatus(); END DiffViewerStatus status = new DiffViewerStatus(); applicationStatus.setDiffViewerStatus(status); applicationStatus.setConfiguration(getConfiguration()); applicationStatus.setSearchEngineStatus(SearchEngineStatus.create()); applicationStatus.setVersion(ApplicationVersionHolder.INSTANCE.getApplicationVersion()); return applicationStatus; } This class has Constructor and getter/setter which are never used.

Target:
public ApplicationStatus getApplicationStatus() { ApplicationStatus applicationStatus = new ApplicationStatus(); applicationStatus.setConfiguration(getConfiguration()); applicationStatus.setSearchEngineStatus(SearchEngineStatus.create()); applicationStatus.setVersion(ApplicationVersionHolder.INSTANCE.getApplicationVersion()); return applicationStatus; }
Source:
private ApiInfo apiInfo() { START Collection<VendorExtension> vendorExtensions = new ArrayList<>(); END return new ApiInfo( "Oppijan verkkopalvelukokonaisuus / ePerusteet rajapinta", "", "Spring MVC API based on the swagger 2.0 and 1.2 specification", "https://confluence.csc.fi/display/oppija/Rajapinnat+toisen+asteen+ja+perusasteen+toimijoille", null, "EUPL 1.1", "http://ec.europa.eu/idabc/eupl", vendorExtensions); } Inline?

Target:
private ApiInfo apiInfo() { return new ApiInfo( "Oppijan verkkopalvelukokonaisuus / ePerusteet rajapinta", "", "Spring MVC API based on the swagger 2.0 and 1.2 specification", "https://confluence.csc.fi/display/oppija/Rajapinnat+toisen+asteen+ja+perusasteen+toimijoille", null, "EUPL 1.1", "http://ec.europa.eu/idabc/eupl", new ArrayList<>()); }
Source:
public WebViewPage(WebDriver driver) { START super(driver); END webViewDriver = (AppiumDriver) (((EventFiringWebDriver) getDriver()).getWrappedDriver()); Set contextNames = webViewDriver.getContextHandles(); contextNames.forEach(System.out::println); webViewContext = contextNames.toArray()[1].toString(); } - Please rewrite constructor according to project style guide.

Target:
public WebViewPage(WebDriver driver) { super(driver); }
Source:
START public static PublicSuffixMatcher load(final InputStream in) throws IOException { END Args.notNull(in, "InputStream"); final List<PublicSuffixList> lists = new PublicSuffixListParser().parseByType( new InputStreamReader(in, StandardCharsets.UTF_8)); return new PublicSuffixMatcher(lists); } @nielsbasjes Is making this method public really necessary? Do we need to expose this method in the public APIs? Can't it be package private?

Target:
private static PublicSuffixMatcher load(final InputStream in) throws IOException { final List<PublicSuffixList> lists = new PublicSuffixListParser().parseByType( new InputStreamReader(in, StandardCharsets.UTF_8)); return new PublicSuffixMatcher(lists); }
Source:
static boolean isWeakCipherSuite(final String cipherSuite) { START final String normalizedCipherSuite = cipherSuite.toUpperCase(); END for (final Pattern pattern : WEAK_CIPHER_SUITE_PATTERNS) { if (pattern.matcher(normalizedCipherSuite).matches()) { return true; } } return false; } @artem-smotrakov Please use `#toUpperCase` with `Locale#ROOT` parameter. Alternatively you might want to use non-case sensitive regex matching now.

Target:
static boolean isWeakCipherSuite(final String cipherSuite) { for (final Pattern pattern : WEAK_CIPHER_SUITE_PATTERNS) { if (pattern.matcher(cipherSuite).matches()) { return true; } } return false; }
Source:
private boolean isValidImport(String part, int executionCount) { try { CompletableFuture<Boolean> validImportFuture = new CompletableFuture<>(); START kernel.executeCode("Class.forName(\"" + part + "\")", new Message(), executionCount, seo -> { END validImportFuture.complete(!seo.getStatus().equals(EvaluationStatus.ERROR)); }); return validImportFuture.get(); } catch (InterruptedException | ExecutionException e) { return Boolean.FALSE; } } There should be a more more direct way of doing this that doesn't use executeCode like this. For example, this will fail with the Clojure kernel.

Target:
private boolean isValidImport(String part, int executionCount) { try { CompletableFuture<Boolean> validImportFuture = new CompletableFuture<>(); kernel.executeCode("", new Message(), executionCount, seo -> validImportFuture.complete(!seo.getStatus().equals(EvaluationStatus.ERROR))); return validImportFuture.get(); } catch (InterruptedException | ExecutionException e) { return Boolean.FALSE; } }
Source:
private boolean isValidImport(String part, int executionCount) { try { part = part.replace(";",""); CompletableFuture<Boolean> validImportFuture = new CompletableFuture<>(); START kernel.executeCode("Class.forName(\"" + part + "\");", new Message(), executionCount, END seo -> validImportFuture.complete(!seo.getStatus().equals(EvaluationStatus.ERROR))); return validImportFuture.get(); } catch (InterruptedException | ExecutionException e) { return Boolean.FALSE; } } please use the empty cell hack.

Target:
private boolean isValidImport(String part, int executionCount) { try { CompletableFuture<Boolean> validImportFuture = new CompletableFuture<>(); kernel.executeCode("", new Message(), executionCount, seo -> validImportFuture.complete(!seo.getStatus().equals(EvaluationStatus.ERROR))); return validImportFuture.get(); } catch (InterruptedException | ExecutionException e) { return Boolean.FALSE; } }
Source:
private void handleSetDetails(Message message) { if (isCorrectEvent(message, CommActions.ACTIONDETAILS)) { handleCommEventSync(message, CommActions.ACTIONDETAILS, this::onActionDetails); } START LOGGER.warn("Warning: set details handler received non-set details message " + message.toString()); END } the warning should be inside the conditional.

Target:
private void handleSetDetails(Message message) { if (isCorrectEvent(message, CommActions.ACTIONDETAILS)) { handleCommEventSync(message, CommActions.ACTIONDETAILS, this::onActionDetails); } }
Source:
protected boolean checkValue(final Object value) { START return value instanceof Date; END } needs to take Dates AND Strings

Target:
protected boolean checkValue(final Object value) { return value instanceof Date || value instanceof String; }
Source:
START public Boolean getDisableKerberos() { END return this.disableKerberosPref; } is there a reason we have accessors here? the enclosing class can read the members directly. also, "this" is not needed. might be best to just move this class to its own file.

Target:
Boolean getDisableKerberos() { return this.disableKerberosPref; }
Source:
public void serialize(StringObject value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException { START synchronized (value) { END jgen.writeStartObject(); jgen.writeObjectField("value", value.getText()); jgen.writeEndObject(); } } no need to synchronize as value (a StringObject) is immutable.

Target:
public void serialize(StringObject value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException { jgen.writeStartObject(); jgen.writeObjectField("value", value.getText()); jgen.writeEndObject(); }
Source:
public void serialize(TableDisplay value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException { START jgen.writeStartObject(); END jgen.writeObjectField("type", "TableDisplay"); jgen.writeObjectField("columnNames", value.columns); jgen.writeObjectField("values", value.values); jgen.writeEndObject(); } if TableDisplay is mutable we should synchronize here.

Target:
public void serialize(TableDisplay value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException { synchronized (value) { jgen.writeStartObject(); jgen.writeObjectField("type", "TableDisplay"); jgen.writeObjectField("columnNames", value.columns); jgen.writeObjectField("values", value.values); jgen.writeEndObject(); } }
Source:
private FluentIterable<Event> filterByDateStart(final LocalDateTime dateStart, FluentIterable<Event> results) { return results.filter(new Predicate<Event>() { @Override public boolean apply(@Nullable Event event) { START assert event != null; END return dateStart == null || event.getDate().isAfter(dateStart) || event.getDate().isEqual(dateStart); } }); } @Nullable et après tu fais assert != null?

Target:
private FluentIterable<Event> filterByDateStart(final LocalDateTime dateStart, FluentIterable<Event> results) { return results.filter(new Predicate<Event>() { @Override public boolean apply(@Nullable Event event) { return event != null && (dateStart == null || event.getDate().isAfter(dateStart) || event.getDate().isEqual(dateStart)); } }); }