idx int64 0 165k | question stringlengths 73 4.15k | target stringlengths 5 918 | len_question int64 21 890 | len_target int64 3 255 |
|---|---|---|---|---|
36,000 | @ SuppressWarnings ( "rawtypes" ) @ Override public void transform ( ITestAnnotation annotation , Class testClass , Constructor testConstructor , Method testMethod ) { annotation . setInvocationCount ( StringUtils . countMatches ( getBrowser ( ) , "," ) + 1 ) ; } | overrides the basic TestNG transform function to provide dynamic access to an invocation count | 68 | 17 |
36,001 | private boolean isRealBrowser ( ) { Browser browser = capabilities . getBrowser ( ) ; return browser . getName ( ) != BrowserName . NONE && browser . getName ( ) != BrowserName . HTMLUNIT ; } | Determines if a real browser is being used . If the browser is NONE or HTMLUNIT it is not considered a real browser | 47 | 28 |
36,002 | private String generateFilename ( ) { String counter = "" ; if ( capabilities . getInstance ( ) > 0 ) { counter = "_" + capabilities . getInstance ( ) ; } return test + counter ; } | Generates a unique filename based on the package class method name and invocation count | 43 | 15 |
36,003 | private void setupFile ( ) { if ( ! new File ( directory ) . exists ( ) && ! new File ( directory ) . mkdirs ( ) ) { try { throw new IOException ( "Unable to create output directory" ) ; } catch ( IOException e ) { log . info ( e ) ; } } if ( ! file . exists ( ) ) { try { if ( ! file . createNewFile ( ) ) { throw new I... | Creates the directory and file to hold the test output file | 126 | 12 |
36,004 | private void replaceInFile ( String oldText , String newText ) { StringBuilder oldContent = new StringBuilder ( ) ; try ( FileReader fr = new FileReader ( file ) ; BufferedReader reader = new BufferedReader ( fr ) ) { String line ; while ( ( line = reader . readLine ( ) ) != null ) { oldContent . append ( line ) ; oldC... | Replaces an occurrence of a string within a file | 179 | 10 |
36,005 | private String getHtmlForPDFConversion ( ) throws IOException { StringBuilder oldContent = new StringBuilder ( ) ; FileReader fr = new FileReader ( file ) ; try ( BufferedReader reader = new BufferedReader ( fr ) ) { String line ; while ( ( line = reader . readLine ( ) ) != null ) { oldContent . append ( line ) ; oldCo... | Removes all elements that cannot be converted to pdf this method is to be used before converting the html file to pdf with openhtmltopdf . pdfboxout . PdfRendererBuilder | 421 | 40 |
36,006 | public String captureEntirePageScreenshot ( ) { String imageName = generateImageName ( ) ; String imageLink = generateImageLink ( imageName ) ; try { app . takeScreenshot ( imageName ) ; screenshots . add ( imageName ) ; } catch ( Exception e ) { log . error ( e ) ; imageLink = "<br/><b><font class='fail'>No Screenshot... | Captures the entire page screen shot and created an HTML file friendly link to place in the output file | 95 | 20 |
36,007 | private String getAction ( String check , double waitFor ) { String action = "" ; if ( waitFor > 0 ) { action = "Waiting up to " + waitFor + " seconds " + check ; } return action ; } | Helper to recordStep which takes in a check being performed and determines if a wait is occuring or not . If no wait no action is recorded . If a wait was performed that wait is added to the check and provided back as the action | 49 | 48 |
36,008 | private String getActual ( String actual , double timeTook ) { if ( timeTook > 0 ) { String lowercase = actual . substring ( 0 , 1 ) . toLowerCase ( ) ; actual = "After waiting for " + timeTook + " seconds, " + lowercase + actual . substring ( 1 ) ; } return actual ; } | Helper to recordStep which takes in some result and appends a time waited if appropriate . If timeTook is greater than zero some time was waited along with the action and the returned result will reflect that | 77 | 41 |
36,009 | public void pass ( String action , String expectedResult , String actualResult ) { passes ++ ; recordStep ( action , expectedResult , actualResult , false , Success . PASS ) ; } | Records the performed step as a pass to the output file . This includes the action taken if any the expected result and the actual result . | 38 | 28 |
36,010 | public void finalizeReporter ( int testStatus ) { // reopen the file try ( FileWriter fw = new FileWriter ( file , true ) ; BufferedWriter out = new BufferedWriter ( fw ) ) { out . write ( " </table>\n" ) ; out . write ( " </body>\n" ) ; out . write ( "</html>\n" ) ; } catch ( IOException e ) { log . error ( e ) ; } //... | Ends and closes the output test file . The HTML is properly ended and the file is analyzed to determine if the test passed or failed and that information is updated along with the overall timing of the test | 379 | 40 |
36,011 | private void addTimeToReport ( ) { // record the time SimpleDateFormat stf = new SimpleDateFormat ( "HH:mm:ss" ) ; String timeNow = stf . format ( new Date ( ) ) ; long totalTime = ( new Date ( ) ) . getTime ( ) - startTime ; long time = totalTime / 1000 ; StringBuilder seconds = new StringBuilder ( Integer . toString ... | Updates the output file with timing information including run time and finish time | 277 | 14 |
36,012 | private void generatePdf ( ) { File pdfFile = new File ( directory , filename + ".pdf" ) ; try ( OutputStream os = new FileOutputStream ( pdfFile ) ) { PdfRendererBuilder builder = new PdfRendererBuilder ( ) ; builder . withHtmlContent ( getHtmlForPDFConversion ( ) , "file://" + pdfFile . getAbsolutePath ( ) . replaceA... | Generates a pdf report in the same directory as the html report | 132 | 13 |
36,013 | private String generateImageLink ( String imageName ) { StringBuilder imageLink = new StringBuilder ( "<br/>" ) ; if ( imageName . length ( ) >= directory . length ( ) + 1 ) { imageLink . append ( ONCLICK_TOGGLE ) . append ( imageName . substring ( directory . length ( ) + 1 ) ) . append ( "\")'>Toggle Screenshot Thumb... | Generates the HTML friendly link for the image | 293 | 9 |
36,014 | public static String formatResponse ( Response response ) { if ( response == null ) { return "" ; } StringBuilder output = new StringBuilder ( ) ; if ( response . isData ( ) ) { output . append ( DIV_I ) ; Gson gson = new GsonBuilder ( ) . setPrettyPrinting ( ) . create ( ) ; if ( response . getArrayData ( ) != null ) ... | Formats the response parameters to be prettily printed out in HTML | 168 | 13 |
36,015 | public static String formatKeyPair ( Map < String , Object > keyPairs ) { if ( keyPairs == null ) { return "" ; } StringBuilder stringBuilder = new StringBuilder ( ) ; for ( Map . Entry < String , Object > entry : keyPairs . entrySet ( ) ) { stringBuilder . append ( DIV ) ; stringBuilder . append ( entry . getKey ( ) )... | From an object map passed in building a key value set properly html formatted for used in reporting | 143 | 18 |
36,016 | public static String getRequestPayloadOutput ( Request params , File file ) { StringBuilder payload = new StringBuilder ( ) ; String uuid = getUUID ( ) ; payload . append ( ONCLICK_TOGGLE ) . append ( uuid ) . append ( "\")'>Toggle Payload</a> " ) ; payload . append ( SPAN_ID ) . append ( uuid ) . append ( DISPLAY_NONE... | Formats the request parameters to be prettily printed out in HTML | 429 | 13 |
36,017 | public static String getCredentialStringOutput ( HTTP http ) { if ( http == null || ! http . useCredentials ( ) ) { return "" ; } StringBuilder credentials = new StringBuilder ( ) ; String uuid = getUUID ( ) ; credentials . append ( ONCLICK_TOGGLE ) . append ( uuid ) . append ( "\")'>Toggle Credentials</a> " ) ; creden... | Looks for the simple login credentials username and password and if they are both set turns that into a string which will be formatted for HTML to be printed into the output file | 215 | 33 |
36,018 | public static String getRequestHeadersOutput ( HTTP http ) { if ( http == null ) { return "" ; } StringBuilder requestHeaders = new StringBuilder ( ) ; String uuid = getUUID ( ) ; requestHeaders . append ( ONCLICK_TOGGLE ) . append ( uuid ) . append ( "\")'>Toggle Headers</a> " ) ; requestHeaders . append ( SPAN_ID ) .... | Takes the headers set in the HTTP request and writes them to the output file in properly HTML formatted fashion | 154 | 21 |
36,019 | public static String getResponseHeadersOutput ( Response response ) { if ( response == null ) { return "" ; } StringBuilder responseHeaders = new StringBuilder ( ) ; String uuid = getUUID ( ) ; responseHeaders . append ( ONCLICK_TOGGLE ) . append ( uuid ) . append ( "\")'>Toggle Headers</a> " ) ; responseHeaders . appe... | Takes the headers returned in the HTTP response and writes them to the output file in properly HTML formatted fashion | 154 | 21 |
36,020 | public static String getResponseCodeOutput ( Response response ) { if ( response == null ) { return "" ; } StringBuilder responseOutput = new StringBuilder ( ) ; String uuid = getUUID ( ) ; responseOutput . append ( ONCLICK_TOGGLE ) . append ( uuid ) . append ( "\")'>Toggle Response Status Code</a> " ) ; responseOutput... | Takes the response code returned in the HTTP response and writes them to the output file in properly HTML formatted fashion | 154 | 22 |
36,021 | public static String getResponseOutput ( Response response ) { if ( response == null || response . getMessage ( ) == null || "" . equals ( response . getMessage ( ) ) ) { return "" ; } StringBuilder responseOutput = new StringBuilder ( ) ; String uuid = getUUID ( ) ; responseOutput . append ( ONCLICK_TOGGLE ) . append ... | Takes the response returned from the HTTP call and writes it to the output file in properly HTML formatted fashion | 173 | 21 |
36,022 | public static String getUUID ( ) { long timeInSeconds = new Date ( ) . getTime ( ) ; String randomChars = TestCase . getRandomString ( 10 ) ; return timeInSeconds + "_" + randomChars ; } | Generates a unique id | 54 | 5 |
36,023 | public String url ( ) { try { return driver . getCurrentUrl ( ) ; } catch ( Exception e ) { log . warn ( e ) ; return null ; } } | Retrieves the current url of the application . | 36 | 10 |
36,024 | public String title ( ) { try { return driver . getTitle ( ) ; } catch ( Exception e ) { log . warn ( e ) ; return null ; } } | Retrieves the title of the current page the application is on | 35 | 13 |
36,025 | public String htmlSource ( ) { try { return driver . getPageSource ( ) ; } catch ( Exception e ) { log . warn ( e ) ; return null ; } } | Retrieves the full html source of the current page the application is on | 37 | 15 |
36,026 | public Object eval ( String javascriptFunction ) { try { JavascriptExecutor js = ( JavascriptExecutor ) driver ; return js . executeScript ( javascriptFunction ) ; } catch ( NoSuchMethodError | Exception e ) { log . warn ( e ) ; return null ; } } | Executes a provided script and returns the output of that script . If there is an error executing this script a null value will be returned . | 57 | 28 |
36,027 | public String confirmation ( ) { if ( ! is . confirmationPresent ( ) ) { return null ; } try { Alert alert = driver . switchTo ( ) . alert ( ) ; return alert . getText ( ) ; } catch ( Exception e ) { log . warn ( e ) ; return null ; } } | Retrieves the content of a confirmation present on the page . If the confirmation doesn t exist a null value will be returned . | 64 | 26 |
36,028 | public Cookie cookie ( String expectedCookieName ) { try { return driver . manage ( ) . getCookieNamed ( expectedCookieName ) ; } catch ( Exception e ) { log . warn ( e ) ; return null ; } } | Retrieves the full cookie in the application with the provided cookieName . If the cookie doesn t exist a null value will be returned . | 51 | 28 |
36,029 | public String cookieValue ( String expectedCookieName ) { Cookie cookie = cookie ( expectedCookieName ) ; if ( cookie != null ) { return cookie . getValue ( ) ; } return null ; } | Retrieves the cookie value in the application with the provided cookieName . If the cookie doesn t exist a null value will be returned . | 43 | 28 |
36,030 | public String cookiePath ( String expectedCookieName ) { Cookie cookie = cookie ( expectedCookieName ) ; if ( cookie != null ) { return cookie . getPath ( ) ; } return null ; } | Retrieves the cookie path in the application with the provided cookieName . If the cookie doesn t exist a null value will be returned . | 43 | 28 |
36,031 | public String cookieDomain ( String expectedCookieName ) { Cookie cookie = cookie ( expectedCookieName ) ; if ( cookie != null ) { return cookie . getDomain ( ) ; } return null ; } | Retrieves the cookie domain in the application with the provided cookieName . If the cookie doesn t exist a null value will be returned . | 43 | 28 |
36,032 | public Date cookieExpiration ( String expectedCookieName ) { Cookie cookie = cookie ( expectedCookieName ) ; if ( cookie != null ) { return cookie . getExpiry ( ) ; } return null ; } | Retrieves the cookie expiration in the application with the provided cookieName . If the cookie doesn t exist a null value will be returned . | 46 | 28 |
36,033 | public void urlEquals ( double seconds , String expectedURL ) { double end = System . currentTimeMillis ( ) + ( seconds * 1000 ) ; try { WebDriverWait wait = new WebDriverWait ( app . getDriver ( ) , ( long ) seconds , DEFAULT_POLLING_INTERVAL ) ; wait . until ( ExpectedConditions . urlToBe ( expectedURL ) ) ; double t... | Asserts that the provided URL equals the actual URL the application is currently on . This information will be logged and recorded with a screenshot for traceability and added debugging support . | 159 | 35 |
36,034 | private double popup ( double seconds ) { // wait for up to XX seconds for the error message double end = System . currentTimeMillis ( ) + ( seconds * 1000 ) ; WebDriverWait wait = new WebDriverWait ( app . getDriver ( ) , ( long ) seconds , DEFAULT_POLLING_INTERVAL ) ; wait . until ( ExpectedConditions . alertIsPresen... | Wait for a popup to be present and then returns the amount of time that was waited | 118 | 17 |
36,035 | public void alertPresent ( double seconds ) { try { double timeTook = popup ( seconds ) ; checkAlertPresent ( seconds , timeTook ) ; } catch ( TimeoutException e ) { checkAlertPresent ( seconds , seconds ) ; } } | Asserts that an alert is present on the page . This information will be logged and recorded with a screenshot for traceability and added debugging support . | 52 | 30 |
36,036 | public void alertNotPresent ( double seconds ) { try { double timeTook = noPopup ( seconds ) ; checkAlertNotPresent ( seconds , timeTook ) ; } catch ( TimeoutException e ) { checkAlertNotPresent ( seconds , seconds ) ; } } | Waits up to the provided wait time for an alert is not present on the page . This information will be logged and recorded with a screenshot for traceability and added debugging support . | 57 | 36 |
36,037 | public void alertEquals ( double seconds , String expectedAlertText ) { try { double timeTook = popup ( seconds ) ; timeTook = popupEquals ( seconds - timeTook , expectedAlertText ) ; checkAlertEquals ( expectedAlertText , seconds , timeTook ) ; } catch ( TimeoutException e ) { checkAlertEquals ( expectedAlertText , se... | Waits up to the provided wait time for an alert present on the page has content equal to the expected text . This information will be logged and recorded with a screenshot for traceability and added debugging support . | 87 | 41 |
36,038 | public void alertMatches ( double seconds , String expectedAlertPattern ) { try { double timeTook = popup ( seconds ) ; timeTook = popupMatches ( seconds - timeTook , expectedAlertPattern ) ; checkAlertMatches ( expectedAlertPattern , seconds , timeTook ) ; } catch ( TimeoutException e ) { checkAlertMatches ( expectedA... | Waits up to the provided wait time for an alert present on the page has content matching the expected patten . This information will be logged and recorded with a screenshot for traceability and added debugging support . | 87 | 41 |
36,039 | public void confirmationPresent ( double seconds ) { try { double timeTook = popup ( seconds ) ; checkConfirmationPresent ( seconds , timeTook ) ; } catch ( TimeoutException e ) { checkConfirmationPresent ( seconds , seconds ) ; } } | Waits up to the provided wait time for a confirmation is present on the page . This information will be logged and recorded with a screenshot for traceability and added debugging support . | 54 | 35 |
36,040 | public void confirmationNotPresent ( double seconds ) { try { double timeTook = noPopup ( seconds ) ; checkConfirmationNotPresent ( seconds , timeTook ) ; } catch ( TimeoutException e ) { checkConfirmationNotPresent ( seconds , seconds ) ; } } | Waits up to the provided wait time for a confirmation is not present on the page . This information will be logged and recorded with a screenshot for traceability and added debugging support . | 59 | 36 |
36,041 | public void confirmationEquals ( double seconds , String expectedConfirmationText ) { try { double timeTook = popup ( seconds ) ; timeTook = popupEquals ( seconds - timeTook , expectedConfirmationText ) ; checkConfirmationEquals ( expectedConfirmationText , seconds , timeTook ) ; } catch ( TimeoutException e ) { checkC... | Waits up to the provided wait time for a confirmation present on the page has content equal to the expected text . This information will be logged and recorded with a screenshot for traceability and added debugging support . | 93 | 41 |
36,042 | public void confirmationMatches ( double seconds , String expectedConfirmationPattern ) { try { double timeTook = popup ( seconds ) ; timeTook = popupMatches ( seconds - timeTook , expectedConfirmationPattern ) ; checkConfirmationMatches ( expectedConfirmationPattern , seconds , timeTook ) ; } catch ( TimeoutException ... | Waits up to the provided wait time for a confirmation present on the page has content matching the expected text . This information will be logged and recorded with a screenshot for traceability and added debugging support . | 93 | 40 |
36,043 | public void promptPresent ( double seconds ) { try { double timeTook = popup ( seconds ) ; checkPromptPresent ( seconds , timeTook ) ; } catch ( TimeoutException e ) { checkPromptPresent ( seconds , seconds ) ; } } | Waits up to the provided wait time for a prompt is present on the page . This information will be logged and recorded with a screenshot for traceability and added debugging support . | 54 | 35 |
36,044 | public void promptNotPresent ( double seconds ) { try { double timeTook = noPopup ( seconds ) ; checkPromptNotPresent ( seconds , timeTook ) ; } catch ( TimeoutException e ) { checkPromptNotPresent ( seconds , seconds ) ; } } | Waits up to the provided wait time for a prompt is not present on the page . This information will be logged and recorded with a screenshot for traceability and added debugging support . | 59 | 36 |
36,045 | public void promptEquals ( double seconds , String expectedPromptText ) { try { double timeTook = popup ( seconds ) ; timeTook = popupEquals ( seconds - timeTook , expectedPromptText ) ; checkPromptEquals ( expectedPromptText , seconds , timeTook ) ; } catch ( TimeoutException e ) { checkPromptEquals ( expectedPromptTe... | Waits up to the provided wait time for a prompt present on the page has content equal to the expected text . This information will be logged and recorded with a screenshot for traceability and added debugging support . | 93 | 41 |
36,046 | public void promptMatches ( double seconds , String expectedPromptPattern ) { try { double timeTook = popup ( seconds ) ; timeTook = popupMatches ( seconds - timeTook , expectedPromptPattern ) ; checkPromptMatches ( expectedPromptPattern , seconds , timeTook ) ; } catch ( TimeoutException e ) { checkPromptMatches ( exp... | Waits up to the provided wait time for a prompt present on the page has content matching the expected text . This information will be logged and recorded with a screenshot for traceability and added debugging support . | 93 | 40 |
36,047 | public void cookieExists ( double seconds , String expectedCookieName ) { double end = System . currentTimeMillis ( ) + ( seconds * 1000 ) ; while ( ! app . is ( ) . cookiePresent ( expectedCookieName ) && System . currentTimeMillis ( ) < end ) ; double timeTook = Math . min ( ( seconds * 1000 ) - ( end - System . curr... | Waits up to the provided wait time for a cookie exists in the application with the provided cookieName . This information will be logged and recorded with a screenshot for traceability and added debugging support . | 118 | 39 |
36,048 | public void cookieNotExists ( double seconds , String unexpectedCookieName ) { double end = System . currentTimeMillis ( ) + ( seconds * 1000 ) ; while ( app . is ( ) . cookiePresent ( unexpectedCookieName ) && System . currentTimeMillis ( ) < end ) ; double timeTook = Math . min ( ( seconds * 1000 ) - ( end - System .... | Waits up to the provided wait time for a cookie doesn t exist in the application with the provided cookieName . This information will be logged and recorded with a screenshot for traceability and added debugging support . | 119 | 41 |
36,049 | public void cookieEquals ( double seconds , String cookieName , String expectedCookieValue ) { double end = System . currentTimeMillis ( ) + ( seconds * 1000 ) ; while ( app . is ( ) . cookiePresent ( cookieName ) && System . currentTimeMillis ( ) < end ) ; if ( app . is ( ) . cookiePresent ( cookieName ) ) { while ( !... | Waits up to the provided wait time for a cookies with the provided name has a value equal to the expected value . This information will be logged and recorded with a screenshot for traceability and added debugging support . | 175 | 42 |
36,050 | public void cookieMatches ( double seconds , String cookieName , String expectedCookiePattern ) { double end = System . currentTimeMillis ( ) + ( seconds * 1000 ) ; while ( app . is ( ) . cookiePresent ( cookieName ) && System . currentTimeMillis ( ) < end ) ; if ( app . is ( ) . cookiePresent ( cookieName ) ) { while ... | Waits up to the provided wait time for a cookies with the provided name has a value matching the expected pattern . This information will be logged and recorded with a screenshot for traceability and added debugging support . | 175 | 41 |
36,051 | public boolean present ( ) { boolean isPresent = false ; try { element . getWebElement ( ) . getText ( ) ; isPresent = true ; } catch ( NoSuchElementException | StaleElementReferenceException e ) { log . info ( e ) ; } return isPresent ; } | Determines whether the element is present or not . | 61 | 11 |
36,052 | public boolean input ( ) { boolean isInput = false ; try { WebElement webElement = element . getWebElement ( ) ; if ( "input" . equalsIgnoreCase ( webElement . getTagName ( ) ) || "textarea" . equalsIgnoreCase ( webElement . getTagName ( ) ) || SELECT . equalsIgnoreCase ( webElement . getTagName ( ) ) ) { isInput = tru... | Determines whether the element is an input or not . An input could be an input element a textarea or a select | 115 | 25 |
36,053 | public boolean select ( ) { boolean isSelect = false ; try { WebElement webElement = element . getWebElement ( ) ; if ( SELECT . equalsIgnoreCase ( webElement . getTagName ( ) ) ) { isSelect = true ; } } catch ( NoSuchElementException e ) { log . info ( e ) ; } return isSelect ; } | Determines whether the element is a select or not . | 76 | 12 |
36,054 | public boolean table ( ) { boolean isTable = false ; try { WebElement webElement = element . getWebElement ( ) ; if ( "table" . equalsIgnoreCase ( webElement . getTagName ( ) ) ) { isTable = true ; } } catch ( NoSuchElementException e ) { log . info ( e ) ; } return isTable ; } | Determines whether the element is a table or not . | 78 | 12 |
36,055 | public boolean enabled ( ) { boolean isEnabled = false ; try { // adding additional check for disabled attribute, due to issues with safari isEnabled = ( element . getWebElement ( ) . isEnabled ( ) && ! element . get ( ) . allAttributes ( ) . containsKey ( "disabled" ) ) ; } catch ( NullPointerException | NoSuchElement... | Determines whether the element is enabled or not . | 112 | 11 |
36,056 | public boolean checked ( ) { boolean isChecked = false ; try { isChecked = element . getWebElement ( ) . isSelected ( ) ; } catch ( Exception e ) { log . info ( e ) ; } return isChecked ; } | Determines whether the element is checked or not . | 54 | 11 |
36,057 | public boolean displayed ( ) { boolean isDisplayed = false ; try { isDisplayed = element . getWebElement ( ) . isDisplayed ( ) ; } catch ( NoSuchElementException e ) { log . info ( e ) ; } return isDisplayed ; } | Determines whether the element is displayed or not . | 57 | 11 |
36,058 | public boolean somethingSelected ( ) { boolean isSelected = false ; if ( input ( ) ) { WebElement webElement = element . getWebElement ( ) ; if ( "input" . equalsIgnoreCase ( webElement . getTagName ( ) ) ) { isSelected = webElement . isSelected ( ) ; } else if ( SELECT . equalsIgnoreCase ( webElement . getTagName ( ) ... | Determines whether the element has something selected or not . Checkboxes radio buttons and selects could all have something selected . Other elements will default to false . | 132 | 31 |
36,059 | public void cssValue ( String attribute , String expectedValue ) { String cssValue = checkCssValue ( attribute , expectedValue , 0 , 0 ) ; String reason = NO_ELEMENT_FOUND ; if ( cssValue == null && expectedValue != null && getElement ( ) . is ( ) . present ( ) ) { reason = "CSS attribute not found" ; } assertFalse ( r... | Asserts that the element has a css attribute with a value equal to the value provided . If the element isn t present or the css doesn t contain the desired attribute this will constitute a failure same as a mismatch . This information will be logged and recorded with a screenshot for traceability and added debugging su... | 121 | 64 |
36,060 | public void attribute ( String attribute , String expectedValue ) { String value = checkAttribute ( attribute , expectedValue , 0 , 0 ) ; String reason = NO_ELEMENT_FOUND ; if ( value == null && getElement ( ) . is ( ) . present ( ) ) { reason = "Attribute doesn't exist" ; } assertNotNull ( reason , value ) ; assertEqu... | Asserts that the element has an attribute with a value equals to the value provided . If the element isn t present or the element does not have the attribute this will constitute a failure same as a mismatch . This information will be logged and recorded with a screenshot for traceability and added debugging support . | 97 | 60 |
36,061 | public void text ( String expectedText ) { String text = checkText ( expectedText , 0 , 0 ) ; assertNotNull ( NO_ELEMENT_FOUND , text ) ; assertEquals ( "Text Mismatch" , expectedText , text ) ; } | Asserts that the element s text equals the provided expected text . If the element isn t present this will constitute a failure same as a mismatch . This information will be logged and recorded with a screenshot for traceability and added debugging support . | 57 | 48 |
36,062 | public void text ( int row , int col , String expectedText ) { String text = checkText ( row , col , expectedText , 0 , 0 ) ; String reason = NO_ELEMENT_FOUND ; if ( text == null && getElement ( ) . is ( ) . present ( ) ) { reason = "Element not table" ; } assertNotNull ( reason , text ) ; assertEquals ( "Text Mismatch... | Asserts that the element s text in a particular cell equals the provided expected text . If the element isn t present or a table this will constitute a failure same as a mismatch . This information will be logged and recorded with a screenshot for traceability and added debugging support . | 101 | 55 |
36,063 | public void value ( String expectedValue ) { String value = checkValue ( expectedValue , 0 , 0 ) ; String reason = NO_ELEMENT_FOUND ; if ( value == null && getElement ( ) . is ( ) . present ( ) ) { reason = "Element not input" ; } assertNotNull ( reason , value ) ; assertEquals ( "Value Mismatch" , expectedValue , valu... | Asserts that the element s value equals the provided expected value . If the element isn t present or an input this will constitute a failure same as a mismatch . This information will be logged and recorded with a screenshot for traceability and added debugging support . | 91 | 51 |
36,064 | public void selectedOption ( String expectedText ) { String option = checkSelectedOption ( expectedText , 0 , 0 ) ; String reason = NO_ELEMENT_FOUND ; if ( option == null && getElement ( ) . is ( ) . present ( ) ) { reason = ELEMENT_NOT_SELECT ; } assertNotNull ( reason , option ) ; assertEquals ( "Selected Option Mism... | Asserts that the element s selected option equals the provided expected option . If the element isn t present or a select this will constitute a failure same as a mismatch . This information will be logged and recorded with a screenshot for traceability and added debugging support . | 97 | 52 |
36,065 | public void selectedValue ( String expectedValue ) { String value = checkSelectedValue ( expectedValue , 0 , 0 ) ; String reason = NO_ELEMENT_FOUND ; if ( value == null && getElement ( ) . is ( ) . present ( ) ) { reason = ELEMENT_NOT_SELECT ; } assertNotNull ( reason , value ) ; assertEquals ( "Selected Value Mismatch... | Asserts that the element s selected value equals the provided expected value . If the element isn t present or a select this will constitute a failure same as a mismatch . This information will be logged and recorded with a screenshot for traceability and added debugging support . | 97 | 52 |
36,066 | public void selectOptions ( String ... expectedOptions ) { String [ ] options = checkSelectOptions ( expectedOptions , 0 , 0 ) ; String reason = NO_ELEMENT_FOUND ; if ( options == null && getElement ( ) . is ( ) . present ( ) ) { reason = ELEMENT_NOT_SELECT ; } assertNotNull ( reason , options ) ; assertEquals ( "Selec... | Asserts that the element s select options equal the provided expected options . If the element isn t present or a select this will constitute a failure same as a mismatch . This information will be logged and recorded with a screenshot for traceability and added debugging support . | 113 | 52 |
36,067 | public void selectValues ( String ... expectedValues ) { String [ ] values = checkSelectValues ( expectedValues , 0 , 0 ) ; String reason = NO_ELEMENT_FOUND ; if ( values == null && getElement ( ) . is ( ) . present ( ) ) { reason = ELEMENT_NOT_SELECT ; } assertNotNull ( reason , values ) ; assertEquals ( "Selected Val... | Asserts that the element s select values equal the provided expected values . If the element isn t present or a select this will constitute a failure same as a mismatch . This information will be logged and recorded with a screenshot for traceability and added debugging support . | 113 | 52 |
36,068 | public void text ( int row , int col , String text ) { text ( row , col , text , defaultWait ) ; } | Waits for the element s text in a particular cell equals the provided expected text . If the element isn t present or a table this will constitute a failure same as a mismatch . The default wait time will be used and if the element doesn t have the desired match count at that time it will fail and log the issue with a ... | 27 | 75 |
36,069 | public void clazz ( String expectedClass , double seconds ) { double end = System . currentTimeMillis ( ) + ( seconds * 1000 ) ; try { elementPresent ( seconds ) ; while ( ! ( expectedClass == null ? element . get ( ) . attribute ( CLASS ) == null : expectedClass . equals ( element . get ( ) . attribute ( CLASS ) ) ) &... | Waits for the element s class equals the provided expected class . If the element isn t present this will constitute a failure same as a mismatch . The provided wait time will be used and if the element doesn t have the desired match count at that time it will fail and log the issue with a screenshot for traceability a... | 163 | 68 |
36,070 | public void attribute ( String attribute , String expectedValue , double seconds ) { double end = System . currentTimeMillis ( ) + ( seconds * 1000 ) ; try { elementPresent ( seconds ) ; while ( ! expectedValue . equals ( element . get ( ) . attribute ( attribute ) ) && System . currentTimeMillis ( ) < end ) ; double t... | Waits for the element has an attribute with a value equals to the value provided . If the element isn t present or the element does not have the attribute this will constitute a failure same as a mismatch . The provided wait time will be used and if the element doesn t have the desired match count at that time it will ... | 147 | 80 |
36,071 | public void text ( String expectedText , double seconds ) { double end = System . currentTimeMillis ( ) + ( seconds * 1000 ) ; try { double timeTook = elementPresent ( seconds ) ; WebDriverWait wait = new WebDriverWait ( element . getDriver ( ) , ( long ) ( seconds - timeTook ) , DEFAULT_POLLING_INTERVAL ) ; wait . unt... | Waits for the element s text equals the provided expected text . If the element isn t present this will constitute a failure same as a mismatch . The provided wait time will be used and if the element doesn t have the desired match count at that time it will fail and log the issue with a screenshot for traceability and... | 181 | 68 |
36,072 | public void text ( int row , int col , String expectedText , double seconds ) { double end = System . currentTimeMillis ( ) + ( seconds * 1000 ) ; try { elementPresent ( seconds ) ; while ( ! element . get ( ) . tableCell ( row , col ) . get ( ) . text ( ) . equals ( expectedText ) && System . currentTimeMillis ( ) < e... | Waits for the element s text in a particular cell equals the provided expected text . If the element isn t present or a table this will constitute a failure same as a mismatch . The provided wait time will be used and if the element doesn t have the desired match count at that time it will fail and log the issue with a... | 165 | 75 |
36,073 | public void value ( String expectedValue , double seconds ) { double end = System . currentTimeMillis ( ) + ( seconds * 1000 ) ; try { double timeTook = elementPresent ( seconds ) ; WebDriverWait wait = new WebDriverWait ( element . getDriver ( ) , ( long ) ( seconds - timeTook ) , DEFAULT_POLLING_INTERVAL ) ; wait . u... | Waits for the element s value equals the provided expected value . If the element isn t present or an input this will constitute a failure same as a mismatch . The provided wait time will be used and if the element doesn t have the desired match count at that time it will fail and log the issue with a screenshot for tr... | 181 | 71 |
36,074 | public void selectedOption ( String expectedText , double seconds ) { double end = System . currentTimeMillis ( ) + ( seconds * 1000 ) ; try { elementPresent ( seconds ) ; if ( ! element . is ( ) . select ( ) ) { throw new TimeoutException ( ELEMENT_NOT_SELECT ) ; } while ( ! element . get ( ) . selectedOption ( ) . eq... | Waits for the element s selected option equals the provided expected option . If the element isn t present or a select this will constitute a failure same as a mismatch . The provided wait time will be used and if the element doesn t have the desired match count at that time it will fail and log the issue with a screen... | 174 | 72 |
36,075 | public void selectedValue ( String expectedValue , double seconds ) { double end = System . currentTimeMillis ( ) + ( seconds * 1000 ) ; try { elementPresent ( seconds ) ; if ( ! element . is ( ) . select ( ) ) { throw new TimeoutException ( ELEMENT_NOT_SELECT ) ; } while ( ! element . get ( ) . selectedValue ( ) . equ... | Waits for the element s selected value equals the provided expected value . If the element isn t present or a select this will constitute a failure same as a mismatch . The provided wait time will be used and if the element doesn t have the desired match count at that time it will fail and log the issue with a screensh... | 174 | 72 |
36,076 | public void selectOptions ( String [ ] expectedOptions , double seconds ) { double end = System . currentTimeMillis ( ) + ( seconds * 1000 ) ; try { elementPresent ( seconds ) ; if ( ! element . is ( ) . select ( ) ) { throw new TimeoutException ( ELEMENT_NOT_SELECT ) ; } while ( ! Arrays . toString ( element . get ( )... | Waits for the element s select options equal the provided expected options . If the element isn t present or a select this will constitute a failure same as a mismatch . The provided wait time will be used and if the element doesn t have the desired match count at that time it will fail and log the issue with a screens... | 188 | 72 |
36,077 | public void selectValues ( String [ ] expectedValues , double seconds ) { double end = System . currentTimeMillis ( ) + ( seconds * 1000 ) ; try { elementPresent ( seconds ) ; if ( ! element . is ( ) . select ( ) ) { throw new TimeoutException ( ELEMENT_NOT_SELECT ) ; } while ( ! Arrays . toString ( element . get ( ) .... | Waits for the element s select values equal the provided expected values . If the element isn t present or a select this will constitute a failure same as a mismatch . The provided wait time will be used and if the element doesn t have the desired match count at that time it will fail and log the issue with a screensho... | 188 | 72 |
36,078 | public static BrowserName lookup ( String b ) throws InvalidBrowserException { for ( BrowserName browser : BrowserName . values ( ) ) { if ( browser . name ( ) . equalsIgnoreCase ( b ) ) { return browser ; } } throw new InvalidBrowserException ( "The selected browser " + b + " is not an applicable choice" ) ; } | allows the browser selected to be passed in with a case insensitive name | 74 | 13 |
36,079 | public void text ( String expectedPattern ) { String text = checkText ( expectedPattern , 0 , 0 ) ; assertNotNull ( NO_ELEMENT_FOUND , text ) ; assertTrue ( "Text Mismatch: text of '" + text + DOES_NOT_MATCH_PATTERN + expectedPattern + "'" , text . matches ( expectedPattern ) ) ; } | Asserts that the element s text matches the regular expression pattern provided . If the element isn t present this will constitute a failure same as a mismatch . This information will be logged and recorded with a screenshot for traceability and added debugging support . | 82 | 49 |
36,080 | public void text ( int row , int col , String pattern ) { String text = checkText ( row , col , pattern , 0 , 0 ) ; assertNotNull ( NO_ELEMENT_FOUND , text ) ; assertTrue ( "Text Mismatch: text of '" + text + DOES_NOT_MATCH_PATTERN + pattern + "'" , text . matches ( pattern ) ) ; } | Asserts that the element s pattern in a particular cell matches the regular expression pattern provided . If the element isn t present or a table this will constitute a failure same as a mismatch . This information will be logged and recorded with a screenshot for traceability and added debugging support . | 88 | 56 |
36,081 | @ SuppressWarnings ( "squid:S2259" ) public void value ( String expectedPattern ) { String value = checkValue ( expectedPattern , 0 , 0 ) ; String reason = NO_ELEMENT_FOUND ; if ( value == null && getElement ( ) . is ( ) . present ( ) ) { reason = "Element not input" ; } assertNotNull ( reason , value ) ; assertTrue ( ... | Asserts that the element s value matches the regular expression pattern provided . If the element isn t present or an input this will constitute a failure same as a mismatch . This information will be logged and recorded with a screenshot for traceability and added debugging support . | 132 | 52 |
36,082 | @ SuppressWarnings ( "squid:S2259" ) public void selectedOption ( String expectedPattern ) { String selectedOption = checkSelectedOption ( expectedPattern , 0 , 0 ) ; String reason = NO_ELEMENT_FOUND ; if ( selectedOption == null && getElement ( ) . is ( ) . present ( ) ) { reason = ELEMENT_NOT_SELECT ; } assertNotNull... | Asserts that the element s selected option matches the regular expression pattern provided . If the element isn t present or a select this will constitute a failure same as a mismatch . This information will be logged and recorded with a screenshot for traceability and added debugging support . | 143 | 53 |
36,083 | @ SuppressWarnings ( "squid:S2259" ) public void selectedValue ( String expectedPattern ) { String selectedValue = checkSelectedValue ( expectedPattern , 0 , 0 ) ; String reason = NO_ELEMENT_FOUND ; if ( selectedValue == null && getElement ( ) . is ( ) . present ( ) ) { reason = ELEMENT_NOT_SELECT ; } assertNotNull ( r... | Asserts that the element s selected value matches the regular expression pattern provided . If the element isn t present or a select this will constitute a failure same as a mismatch . This information will be logged and recorded with a screenshot for traceability and added debugging support . | 143 | 53 |
36,084 | private boolean isPopupPresent ( ) { boolean isPresent = false ; try { driver . switchTo ( ) . alert ( ) ; isPresent = true ; } catch ( NoAlertPresentException e ) { log . info ( e ) ; } return isPresent ; } | Determines if any popup is present on the page | 56 | 11 |
36,085 | public boolean cookiePresent ( String expectedCookieName ) { boolean isCookiePresent = false ; try { if ( driver . manage ( ) . getCookieNamed ( expectedCookieName ) != null ) { isCookiePresent = true ; } return isCookiePresent ; } catch ( Exception e ) { log . error ( e ) ; return false ; } } | Determines if a cookie exists in the application with the provided cookieName . | 78 | 16 |
36,086 | public boolean textPresentInSource ( String expectedText ) { try { return driver . getPageSource ( ) . contains ( expectedText ) ; } catch ( Exception e ) { log . info ( e ) ; return false ; } } | Determines if the provides text is present in the current page source . | 48 | 15 |
36,087 | public void clazz ( String unexpectedClass ) { String clazz = checkClazz ( unexpectedClass , 0 , 0 ) ; assertNotNull ( NO_ELEMENT_FOUND , clazz ) ; assertFalse ( "Class Mismatch: class of '" + clazz + CONTAINS + unexpectedClass + "'" , clazz . contains ( unexpectedClass ) ) ; } | Asserts that the element s class does not contain the provided expected class . If the element isn t present this will constitute a failure same as a mismatch . This information will be logged and recorded with a screenshot for traceability and added debugging support . | 81 | 50 |
36,088 | public void attribute ( String expectedAttribute ) { Set < String > attributes = checkAttribute ( expectedAttribute , 0 , 0 ) ; assertNotNull ( NO_ELEMENT_FOUND , attributes ) ; assertFalse ( "Attribute found: element attributes of '" + String . join ( "," , attributes ) + CONTAINS + expectedAttribute + "'" , attribute... | Asserts that the element does not contain the provided expected attribute . If the element isn t present this will constitute a failure same as a mismatch . This information will be logged and recorded with a screenshot for traceability and added debugging support . | 85 | 48 |
36,089 | public void text ( String expectedText ) { String text = checkText ( expectedText , 0 , 0 ) ; assertNotNull ( NO_ELEMENT_FOUND , text ) ; assertFalse ( "Text found: element text of '" + text + CONTAINS + expectedText + "'" , text . contains ( expectedText ) ) ; } | Asserts that the element s text does not contain the provided expected text . If the element isn t present this will constitute a failure same as a mismatch . This information will be logged and recorded with a screenshot for traceability and added debugging support . | 74 | 50 |
36,090 | @ SuppressWarnings ( "squid:S2259" ) public void value ( String expectedValue ) { String value = checkValue ( expectedValue , 0 , 0 ) ; String reason = NO_ELEMENT_FOUND ; if ( value == null && getElement ( ) . is ( ) . present ( ) ) { reason = "Element not input" ; } assertNotNull ( reason , value ) ; assertFalse ( "Va... | Asserts that the element s value does not contain the provided expected value . If the element isn t present or an input this will constitute a failure same as a mismatch . This information will be logged and recorded with a screenshot for traceability and added debugging support . | 124 | 53 |
36,091 | public void selectValue ( String expectedValue ) { String [ ] values = checkSelectValue ( expectedValue , 0 , 0 ) ; String reason = NO_ELEMENT_FOUND ; if ( values == null && getElement ( ) . is ( ) . present ( ) ) { reason = ELEMENT_NOT_SELECT ; } assertNotNull ( reason , values ) ; assertFalse ( "Value found: element ... | Asserts that the element s options do not contain the provided expected value . If the element isn t present or a select this will constitute a failure same as a mismatch . This information will be logged and recorded with a screenshot for traceability and added debugging support . | 128 | 53 |
36,092 | @ Override public void contains ( Map < String , Object > expectedPairs ) { assertTrue ( "Expected to find " + Reporter . formatKeyPair ( expectedPairs ) , checkContains ( expectedPairs ) ) ; } | Asserts the actual response json payload contains each of the pair values provided and writes that to the output file . If this fails the code will immediately exit and record the error . | 51 | 36 |
36,093 | @ Override public void contains ( JsonElement expectedJson ) { assertTrue ( "Expected to find " + GSON . toJson ( expectedJson ) , checkContains ( expectedJson ) ) ; } | Asserts the actual response json payload contains to the expected json element and writes that out to the output file . If this fails the code will immediately exit and record the error . | 48 | 36 |
36,094 | public Element newElement ( Locator type , String locator ) { return new Element ( driver , reporter , type , locator ) ; } | setups a new element which is located on the page | 29 | 11 |
36,095 | public void wait ( double seconds ) { String action = "Wait " + seconds + SECONDS ; String expected = WAITED + seconds + SECONDS ; try { Thread . sleep ( ( long ) ( seconds * 1000 ) ) ; } catch ( InterruptedException e ) { log . warn ( e ) ; reporter . fail ( action , expected , "Failed to wait " + seconds + SECONDS + ... | Pauses the test for a set amount of time | 130 | 10 |
36,096 | public void goToURL ( String url ) { String action = "Loading " + url ; String expected = "Loaded " + url ; double start = System . currentTimeMillis ( ) ; try { driver . get ( url ) ; } catch ( Exception e ) { log . warn ( e ) ; reporter . fail ( action , expected , "Fail to Load " + url + ". " + e . getMessage ( ) ) ... | Navigates to a new url | 155 | 7 |
36,097 | public void takeScreenshot ( String imageName ) { if ( browser . getName ( ) == BrowserName . HTMLUNIT ) { return ; } try { // take a screenshot File srcFile ; if ( Property . isHubSet ( ) ) { WebDriver augemented = new Augmenter ( ) . augment ( driver ) ; srcFile = ( ( TakesScreenshot ) augemented ) . getScreenshotAs ... | Takes a full screenshot of the entire page | 167 | 9 |
36,098 | public void goBack ( ) { String action = "Going back one page" ; String expected = "Previous page from browser history is loaded" ; try { driver . navigate ( ) . back ( ) ; } catch ( Exception e ) { reporter . fail ( action , expected , "Browser was unable to go back one page. " + e . getMessage ( ) ) ; log . warn ( e ... | Go back one page in the current test s browser history | 99 | 11 |
36,099 | public void setCookie ( Cookie cookie ) { String domain = cookie . getDomain ( ) ; Date expiry = cookie . getExpiry ( ) ; String name = cookie . getName ( ) ; String path = cookie . getPath ( ) ; String value = cookie . getValue ( ) ; String action = "Setting up cookie with attributes:<div><table><tbody><tr><td>Domain<... | Adds a cookie to the application for this particular test | 263 | 10 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.