/** * Example of clicking a button where the 1st first click does not work (possibly due to the page * not blocking correct) and you want to attempt additional tries. Also, example of how to use the * GenericFields class. * * @return some page object */ public SampleDateWidget clickForgotPassword() { int poll = getPollInterval(); int flakyTimeout = poll * getRetries(); FlakinessChecks flaky = new FlakinessChecks(driver, flakyTimeout, poll); int retries = 1; // This could be set to any value. Also, it could be page specific. int count = 0; while (count <= retries) { if (count > 0) Logs.log.warn("Retry (#" + count + ") ..."); fields.click(Field.ForgotPassword); boolean result = flaky.isElementRemoved(sLoc_ForgotPassword); if (result) return new SampleDateWidget(driver); count++; } Logs.logError( "Clicking " + sLog_ForgotPassword + " was not successful after " + retries + " retries as the element was not removed"); return null; }
@Override public void executeRequest() { String response = WS_Util.toString(sendAndReceivePOST()); if (isSuccessful(response)) { Logs.log.info("Request was successful"); Logs.log.info("Tempature for ZIP (" + _ZIP + ") is " + _Temperature); } else Logs.logError("Request failed. Response was following: " + response); }
@Test public void unitTest() { Logs.LOG_PROPS = ConfigRun.UnitTestLoggerPropertiesFile; Logs.initializeLoggers(); Controller.writeTestIDtoLog("POST Request for weather"); WeatherTest gct = new WeatherTest("90210"); // request 1 gct.setOptions(); gct.executeRequest(); // request 2 - reusing same object gct.setZIP("33101"); gct.setOptions(); gct.executeRequest(); Controller.writeTestSuccessToLog("POST Request for weather"); }