idx
int64 0
41.2k
| question
stringlengths 74
4.04k
| target
stringlengths 7
750
|
|---|---|---|
36,100
|
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 , seconds , seconds ) ; } }
|
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 .
|
36,101
|
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 ( expectedAlertPattern , seconds , seconds ) ; } }
|
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 .
|
36,102
|
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 .
|
36,103
|
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 .
|
36,104
|
public void confirmationEquals ( double seconds , String expectedConfirmationText ) { try { double timeTook = popup ( seconds ) ; timeTook = popupEquals ( seconds - timeTook , expectedConfirmationText ) ; checkConfirmationEquals ( expectedConfirmationText , seconds , timeTook ) ; } catch ( TimeoutException e ) { checkConfirmationEquals ( expectedConfirmationText , seconds , seconds ) ; } }
|
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 .
|
36,105
|
public void confirmationMatches ( double seconds , String expectedConfirmationPattern ) { try { double timeTook = popup ( seconds ) ; timeTook = popupMatches ( seconds - timeTook , expectedConfirmationPattern ) ; checkConfirmationMatches ( expectedConfirmationPattern , seconds , timeTook ) ; } catch ( TimeoutException e ) { checkConfirmationMatches ( expectedConfirmationPattern , seconds , seconds ) ; } }
|
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 .
|
36,106
|
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 .
|
36,107
|
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 .
|
36,108
|
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 ( expectedPromptText , seconds , seconds ) ; } }
|
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 .
|
36,109
|
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 ( expectedPromptPattern , seconds , seconds ) ; } }
|
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 .
|
36,110
|
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 . currentTimeMillis ( ) ) , seconds * 1000 ) / 1000 ; checkCookieExists ( expectedCookieName , seconds , timeTook ) ; }
|
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 .
|
36,111
|
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 . currentTimeMillis ( ) ) , seconds * 1000 ) / 1000 ; checkCookieNotExists ( unexpectedCookieName , seconds , timeTook ) ; }
|
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 .
|
36,112
|
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 ( ! app . get ( ) . cookieValue ( cookieName ) . equals ( expectedCookieValue ) && System . currentTimeMillis ( ) < end ) ; } double timeTook = Math . min ( ( seconds * 1000 ) - ( end - System . currentTimeMillis ( ) ) , seconds * 1000 ) / 1000 ; checkCookieEquals ( cookieName , expectedCookieValue , seconds , timeTook ) ; }
|
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 .
|
36,113
|
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 ( ! app . get ( ) . cookieValue ( cookieName ) . matches ( expectedCookiePattern ) && System . currentTimeMillis ( ) < end ) ; } double timeTook = Math . min ( ( seconds * 1000 ) - ( end - System . currentTimeMillis ( ) ) , seconds * 1000 ) / 1000 ; checkCookieMatches ( cookieName , expectedCookiePattern , seconds , timeTook ) ; }
|
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 .
|
36,114
|
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 .
|
36,115
|
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 = true ; } } catch ( NoSuchElementException e ) { log . info ( e ) ; } return isInput ; }
|
Determines whether the element is an input or not . An input could be an input element a textarea or a select
|
36,116
|
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 .
|
36,117
|
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 .
|
36,118
|
public boolean enabled ( ) { boolean isEnabled = false ; try { isEnabled = ( element . getWebElement ( ) . isEnabled ( ) && ! element . get ( ) . allAttributes ( ) . containsKey ( "disabled" ) ) ; } catch ( NullPointerException | NoSuchElementException e ) { log . info ( e ) ; } return isEnabled ; }
|
Determines whether the element is enabled or not .
|
36,119
|
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 .
|
36,120
|
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 .
|
36,121
|
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 ( ) ) ) { Select dropdown = new Select ( webElement ) ; isSelected = ! dropdown . getAllSelectedOptions ( ) . isEmpty ( ) ; } } return isSelected ; }
|
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 .
|
36,122
|
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 ( reason , cssValue == null && expectedValue != null ) ; assertEquals ( "CSS Value Mismatch" , expectedValue , cssValue ) ; }
|
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 support .
|
36,123
|
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 ) ; assertEquals ( "Attribute Mismatch" , expectedValue , value ) ; }
|
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 .
|
36,124
|
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 .
|
36,125
|
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" , expectedText , text ) ; }
|
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 .
|
36,126
|
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 , value ) ; }
|
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 .
|
36,127
|
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 Mismatch" , expectedText , option ) ; }
|
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 .
|
36,128
|
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" , expectedValue , value ) ; }
|
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 .
|
36,129
|
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 ( "Selected Options Mismatch" , Arrays . asList ( expectedOptions ) , Arrays . asList ( options ) ) ; }
|
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 .
|
36,130
|
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 Values Mismatch" , Arrays . asList ( expectedValues ) , Arrays . asList ( values ) ) ; }
|
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 .
|
36,131
|
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 screenshot for traceability and added debugging support .
|
36,132
|
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 ) ) ) && System . currentTimeMillis ( ) < end ) ; double timeTook = Math . min ( ( seconds * 1000 ) - ( end - System . currentTimeMillis ( ) ) , seconds * 1000 ) / 1000 ; checkClazz ( expectedClass , seconds , timeTook ) ; } catch ( TimeoutException e ) { checkClazz ( expectedClass , seconds , seconds ) ; } }
|
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 and added debugging support .
|
36,133
|
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 timeTook = Math . min ( ( seconds * 1000 ) - ( end - System . currentTimeMillis ( ) ) , seconds * 1000 ) / 1000 ; checkAttribute ( attribute , expectedValue , seconds , timeTook ) ; } catch ( TimeoutException e ) { checkAttribute ( attribute , expectedValue , seconds , seconds ) ; } }
|
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 fail and log the issue with a screenshot for traceability and added debugging support .
|
36,134
|
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 . until ( ExpectedConditions . textToBePresentInElementLocated ( element . defineByElement ( ) , expectedText ) ) ; timeTook = Math . min ( ( seconds * 1000 ) - ( end - System . currentTimeMillis ( ) ) , seconds * 1000 ) / 1000 ; checkText ( expectedText , seconds , timeTook ) ; } catch ( TimeoutException e ) { checkText ( expectedText , seconds , seconds ) ; } }
|
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 added debugging support .
|
36,135
|
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 ( ) < end ) ; double timeTook = Math . min ( ( seconds * 1000 ) - ( end - System . currentTimeMillis ( ) ) , seconds * 1000 ) / 1000 ; checkText ( row , col , expectedText , seconds , timeTook ) ; } catch ( TimeoutException e ) { checkText ( row , col , expectedText , seconds , seconds ) ; } }
|
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 screenshot for traceability and added debugging support .
|
36,136
|
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 . until ( ExpectedConditions . textToBePresentInElementValue ( element . defineByElement ( ) , expectedValue ) ) ; timeTook = Math . min ( ( seconds * 1000 ) - ( end - System . currentTimeMillis ( ) ) , seconds * 1000 ) / 1000 ; checkValue ( expectedValue , seconds , timeTook ) ; } catch ( TimeoutException e ) { checkValue ( expectedValue , seconds , seconds ) ; } }
|
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 traceability and added debugging support .
|
36,137
|
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 ( ) . equals ( expectedText ) && System . currentTimeMillis ( ) < end ) ; double timeTook = Math . min ( ( seconds * 1000 ) - ( end - System . currentTimeMillis ( ) ) , seconds * 1000 ) / 1000 ; checkSelectedOption ( expectedText , seconds , timeTook ) ; } catch ( TimeoutException e ) { checkSelectedOption ( expectedText , seconds , seconds ) ; } }
|
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 screenshot for traceability and added debugging support .
|
36,138
|
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 ( ) . equals ( expectedValue ) && System . currentTimeMillis ( ) < end ) ; double timeTook = Math . min ( ( seconds * 1000 ) - ( end - System . currentTimeMillis ( ) ) , seconds * 1000 ) / 1000 ; checkSelectedValue ( expectedValue , seconds , timeTook ) ; } catch ( TimeoutException e ) { checkSelectedValue ( expectedValue , seconds , seconds ) ; } }
|
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 screenshot for traceability and added debugging support .
|
36,139
|
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 ( ) . selectOptions ( ) ) . equals ( Arrays . toString ( expectedOptions ) ) && System . currentTimeMillis ( ) < end ) ; double timeTook = Math . min ( ( seconds * 1000 ) - ( end - System . currentTimeMillis ( ) ) , seconds * 1000 ) / 1000 ; checkSelectOptions ( expectedOptions , seconds , timeTook ) ; } catch ( TimeoutException e ) { checkSelectOptions ( expectedOptions , seconds , seconds ) ; } }
|
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 screenshot for traceability and added debugging support .
|
36,140
|
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 ( ) . selectValues ( ) ) . equals ( Arrays . toString ( expectedValues ) ) && System . currentTimeMillis ( ) < end ) ; double timeTook = Math . min ( ( seconds * 1000 ) - ( end - System . currentTimeMillis ( ) ) , seconds * 1000 ) / 1000 ; checkSelectValues ( expectedValues , seconds , timeTook ) ; } catch ( TimeoutException e ) { checkSelectValues ( expectedValues , seconds , seconds ) ; } }
|
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 screenshot for traceability and added debugging support .
|
36,141
|
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
|
36,142
|
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 .
|
36,143
|
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 .
|
36,144
|
@ 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 ( "Value Mismatch: value of '" + value + DOES_NOT_MATCH_PATTERN + expectedPattern + "'" , value . matches ( expectedPattern ) ) ; }
|
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 .
|
36,145
|
@ 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 ( reason , selectedOption ) ; assertTrue ( "Selected Option Mismatch: option of '" + selectedOption + DOES_NOT_MATCH_PATTERN + expectedPattern + "'" , selectedOption . matches ( expectedPattern ) ) ; }
|
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 .
|
36,146
|
@ 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 ( reason , selectedValue ) ; assertTrue ( "Selected Value Mismatch: value of '" + selectedValue + DOES_NOT_MATCH_PATTERN + expectedPattern + "'" , selectedValue . matches ( expectedPattern ) ) ; }
|
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 .
|
36,147
|
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
|
36,148
|
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 .
|
36,149
|
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 .
|
36,150
|
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 .
|
36,151
|
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 + "'" , attributes . contains ( expectedAttribute ) ) ; }
|
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 .
|
36,152
|
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 .
|
36,153
|
@ 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 ( "Value found: element value of '" + value + CONTAINS + expectedValue + "'" , value . contains ( expectedValue ) ) ; }
|
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 .
|
36,154
|
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 values of '" + String . join ( "," , values ) + CONTAINS + expectedValue + "'" , Arrays . asList ( values ) . contains ( expectedValue ) ) ; }
|
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 .
|
36,155
|
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 .
|
36,156
|
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 .
|
36,157
|
public Element newElement ( Locator type , String locator ) { return new Element ( driver , reporter , type , locator ) ; }
|
setups a new element which is located on the page
|
36,158
|
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 + ". " + e . getMessage ( ) ) ; Thread . currentThread ( ) . interrupt ( ) ; return ; } reporter . pass ( action , expected , WAITED + seconds + SECONDS ) ; }
|
Pauses the test for a set amount of time
|
36,159
|
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 ( ) ) ; return ; } double timeTook = System . currentTimeMillis ( ) - start ; timeTook = timeTook / 1000 ; reporter . pass ( action , expected , "Loaded " + url + " in " + timeTook + SECONDS ) ; acceptCertificate ( ) ; }
|
Navigates to a new url
|
36,160
|
public void takeScreenshot ( String imageName ) { if ( browser . getName ( ) == BrowserName . HTMLUNIT ) { return ; } try { File srcFile ; if ( Property . isHubSet ( ) ) { WebDriver augemented = new Augmenter ( ) . augment ( driver ) ; srcFile = ( ( TakesScreenshot ) augemented ) . getScreenshotAs ( OutputType . FILE ) ; } else { srcFile = ( ( TakesScreenshot ) driver ) . getScreenshotAs ( OutputType . FILE ) ; } FileUtils . copyFile ( srcFile , new File ( imageName ) ) ; } catch ( Exception e ) { log . error ( "IO Error taking screenshot: " + e ) ; } }
|
Takes a full screenshot of the entire page
|
36,161
|
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 ) ; return ; } reporter . pass ( action , expected , expected ) ; }
|
Go back one page in the current test s browser history
|
36,162
|
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</td><td>" + domain + "</tr><tr><td>Expiration</td><td>" + expiry . toString ( ) + "</tr><tr><td>Name</td><td>" + name + "</tr><tr><td>Path</td><td>" + path + "</tr><tr><td>Value</td><td>" + value + "</tr></tbody></table></div><br/>" ; String expected = "Cookie is added" ; try { driver . manage ( ) . addCookie ( cookie ) ; } catch ( Exception e ) { reporter . fail ( action , expected , "Unable to add cookie. " + e . getMessage ( ) ) ; log . warn ( e ) ; return ; } reporter . pass ( action , expected , expected ) ; }
|
Adds a cookie to the application for this particular test
|
36,163
|
public void deleteCookie ( String cookieName ) { String action = "Deleting cookie <i>" + cookieName + "</i>" ; String expected = "Cookie <i>" + cookieName + "</i> is removed" ; try { Cookie cookie = driver . manage ( ) . getCookieNamed ( cookieName ) ; if ( cookie == null ) { reporter . fail ( action , expected , "Unable to remove cookie <i>" + cookieName + "</i> as it doesn't exist." ) ; return ; } driver . manage ( ) . deleteCookieNamed ( cookieName ) ; } catch ( Exception e ) { reporter . fail ( action , expected , "Unable to remove cookie <i>" + cookieName + "</i>. " + e . getMessage ( ) ) ; log . warn ( e ) ; return ; } reporter . pass ( action , expected , expected ) ; }
|
Deletes a stored cookie indicated by the cookieName for this particular test . If the cookie by the provided name isn t present than an error will be logged and recorded
|
36,164
|
public void deleteAllCookies ( ) { String action = "Deleting all cookies" ; String expected = "All cookies are removed" ; try { driver . manage ( ) . deleteAllCookies ( ) ; } catch ( Exception e ) { reporter . fail ( action , expected , "Unable to remove all cookies. " + e . getMessage ( ) ) ; log . warn ( e ) ; return ; } reporter . pass ( action , expected , expected ) ; }
|
Delete all stored cookies for this particular test
|
36,165
|
public void resize ( int width , int height ) { String action = "Resizing browser to " + width + " x " + height ; String expected = "Browser is resized to " + width + " x " + height ; try { Dimension dimension = new Dimension ( width , height ) ; driver . manage ( ) . window ( ) . setSize ( dimension ) ; } catch ( Exception e ) { reporter . fail ( action , expected , "Browser was unable to be resized. " + e . getMessage ( ) ) ; log . warn ( e ) ; return ; } reporter . pass ( action , expected , expected ) ; }
|
Resizes the current window to the specified size
|
36,166
|
public void scroll ( int desiredPosition ) { String action = "Scrolling page by " + desiredPosition + " pixels" ; String expected = "Page is scrolled down " + desiredPosition + " pixels" ; Long newPosition ; try { JavascriptExecutor jse = ( JavascriptExecutor ) driver ; Long initialPosition = ( Long ) jse . executeScript ( "return window.scrollY;" ) ; action = "Scrolling page from " + initialPosition + " to " + desiredPosition ; expected = "Page is now set at position " + desiredPosition ; jse . executeScript ( "window.scrollBy(0, " + desiredPosition + ")" ) ; newPosition = ( Long ) jse . executeScript ( "return window.scrollY;" ) ; } catch ( Exception e ) { reporter . fail ( action , expected , "Unable to scroll on the page. " + e . getMessage ( ) ) ; log . warn ( e ) ; return ; } if ( newPosition != desiredPosition ) { reporter . fail ( action , expected , "Page is set at position " + newPosition ) ; return ; } reporter . pass ( action , expected , "Page is now set at position " + newPosition ) ; }
|
An custom script to scroll to a given position on the page using javascript . If the browser being used doesn t support javascript or the page isn t long enough to support scrolling to the desired position than an error will be logged and recorded
|
36,167
|
public void openNewWindow ( String url ) { String action = "Opening new window to url " + url ; String expected = "New window is opened to url " + url ; try { JavascriptExecutor jse = ( JavascriptExecutor ) driver ; jse . executeScript ( "window.open('" + url + "','_blank');" ) ; } catch ( Exception e ) { reporter . fail ( action , expected , "Unable to open window tab. " + e . getMessage ( ) ) ; log . warn ( e ) ; return ; } switchToNewWindow ( ) ; waitFor ( ) . urlEquals ( url ) ; if ( ! get ( ) . url ( ) . equals ( url ) ) { reporter . fail ( action , expected , "Unable to open new window to " + url ) ; return ; } reporter . pass ( action , expected , expected ) ; acceptCertificate ( ) ; }
|
Opens a new tab and have it selected . The page provided will be loaded
|
36,168
|
public void switchToNewWindow ( ) { String action = "Switching to the new window" ; String expected = "New window is available and selected" ; try { parentWindow = driver . getWindowHandle ( ) ; for ( String winHandle : driver . getWindowHandles ( ) ) { driver . switchTo ( ) . window ( winHandle ) ; } } catch ( Exception e ) { reporter . fail ( action , expected , "New window was unable to be selected. " + e . getMessage ( ) ) ; log . warn ( e ) ; return ; } reporter . pass ( action , expected , expected ) ; }
|
Switches to the next window . This is an alternative to switchNextTab or switchPreviousTab as this works better for some systems and environments that others .
|
36,169
|
public void switchToParentWindow ( ) { String action = "Switching back to parent window" ; String expected = "Parent window is available and selected" ; try { driver . switchTo ( ) . window ( parentWindow ) ; } catch ( Exception e ) { reporter . fail ( action , expected , "Parent window was unable to be selected. " + e . getMessage ( ) ) ; log . warn ( e ) ; return ; } reporter . pass ( action , expected , expected ) ; }
|
Switches to the originally opened window . This is an alternative to switchNextTab or switchPreviousTab as this works better for some systems and environments that others .
|
36,170
|
public void closeCurrentWindow ( ) { String action = "Closing currently selected window" ; String expected = "Current window is closed" ; try { driver . close ( ) ; } catch ( Exception e ) { reporter . fail ( action , expected , "Current window was unable to be closed. " + e . getMessage ( ) ) ; log . warn ( e ) ; return ; } reporter . pass ( action , expected , expected ) ; }
|
Close the currently selected window . After this window is closed ensure that focus is shifted to the next window using switchToNewWindow or switchToParentWindow methods . This is an alternative to closeTab as this works better for some systems and environments that others .
|
36,171
|
public void selectMainWindow ( ) { String action = "Switching to main window" ; String expected = "Main window is selected" ; try { driver . switchTo ( ) . defaultContent ( ) ; } catch ( Exception e ) { reporter . fail ( action , expected , "Main window was not selected. " + e . getMessage ( ) ) ; log . warn ( e ) ; return ; } reporter . pass ( action , expected , expected ) ; }
|
Select the main window . Used for returning to the main content after selecting a frame . If there are nested frames the main content will be selected not the next frame in the parent child relationship
|
36,172
|
public void selectParentFrame ( ) { String action = "Switching to parent frame" ; String expected = "Parent frame is selected" ; try { driver . switchTo ( ) . parentFrame ( ) ; } catch ( Exception e ) { reporter . fail ( action , expected , "Parent frame was not selected. " + e . getMessage ( ) ) ; log . warn ( e ) ; return ; } reporter . pass ( action , expected , expected ) ; }
|
Select the parent frame . Used for returning to the next frame up after selecting a frame . If there are nested frames the main content won t be selected however the next frame in the parent child relationship will be
|
36,173
|
public void acceptCertificate ( ) { String action = "Clicking override link to accept ssl certificate" ; String result = "Override link clicked" ; if ( browser . getName ( ) == BrowserName . INTERNETEXPLORER || browser . getName ( ) == BrowserName . EDGE ) { Element overrideLink = newElement ( Locator . ID , "overridelink" ) ; if ( overrideLink . is ( ) . present ( ) ) { try { if ( browser . getName ( ) == BrowserName . EDGE ) { newElement ( Locator . ID , "moreInformationDropdownSpan" ) . getWebElement ( ) . click ( ) ; } overrideLink . getWebElement ( ) . click ( ) ; reporter . pass ( action , result , result ) ; } catch ( Exception e ) { reporter . fail ( action , result , "Unable to click override link. " + e . getMessage ( ) ) ; log . warn ( e ) ; } } } }
|
Safari Edge and IE don t recognize the allowInsecureCert capability . As a result an alternative method is provided in order to manually accept the problematic certificate
|
36,174
|
private boolean isNotConfirmation ( String action , String expected ) { if ( ! is . confirmationPresent ( ) ) { waitFor . confirmationPresent ( ) ; } if ( ! is . confirmationPresent ( ) ) { reporter . fail ( action , expected , "Unable to click confirmation as it is not present" ) ; return true ; } return false ; }
|
Determines if a confirmation is present or not and can be interacted with . If it s not present an indication that the confirmation can t be clicked on is written to the log file
|
36,175
|
private boolean isNotPrompt ( String action , String expected , String perform ) { if ( ! is . promptPresent ( ) ) { waitFor . promptPresent ( ) ; } if ( ! is . promptPresent ( ) ) { reporter . fail ( action , expected , "Unable to " + perform + " prompt as it is not present" ) ; return true ; } return false ; }
|
Determines if a prompt is present or not and can be interacted with . If it s not present an indication that the confirmation can t be clicked on is written to the log file
|
36,176
|
public void typeIntoPrompt ( String text ) { String action = "Typing text '" + text + "' into prompt" ; String expected = "Prompt is present and enabled to have text " + text + " typed in" ; if ( isNotPrompt ( action , expected , "type into" ) ) { return ; } try { Alert alert = driver . switchTo ( ) . alert ( ) ; alert . sendKeys ( text ) ; } catch ( Exception e ) { reporter . fail ( action , expected , "Unable to type into prompt. " + e . getMessage ( ) ) ; log . warn ( e ) ; return ; } reporter . pass ( action , expected , "Typed text '" + text + "' into prompt" ) ; }
|
Type text into a prompt box
|
36,177
|
public void titleMatches ( String expectedTitlePattern ) { String title = checkTitleMatches ( expectedTitlePattern , 0 , 0 ) ; assertTrue ( "Title Mismatch: title of '" + title + DOES_NOT_MATCH_PATTERN + expectedTitlePattern + "'" , title . matches ( expectedTitlePattern ) ) ; }
|
Verifies the provided title matches the actual title of the current page the application is on . This information will be logged and recorded with a screenshot for traceability and added debugging support .
|
36,178
|
public void alertMatches ( String expectedAlertPattern ) { String alert = checkAlertMatches ( expectedAlertPattern , 0 , 0 ) ; assertTrue ( "Alert Text Mismatch: alert text of '" + alert + DOES_NOT_MATCH_PATTERN + expectedAlertPattern + "'" , alert . matches ( expectedAlertPattern ) ) ; }
|
Asserts that 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 .
|
36,179
|
public void confirmationMatches ( String expectedConfirmationPattern ) { String confirmation = checkConfirmationMatches ( expectedConfirmationPattern , 0 , 0 ) ; assertTrue ( "Confirmation Text Mismatch: confirmation text of '" + confirmation + DOES_NOT_MATCH_PATTERN + expectedConfirmationPattern + "'" , confirmation . matches ( expectedConfirmationPattern ) ) ; }
|
Asserts that 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 .
|
36,180
|
public void promptMatches ( String expectedPromptPattern ) { String prompt = checkPromptMatches ( expectedPromptPattern , 0 , 0 ) ; assertTrue ( "Prompt Text Mismatch: prompt text of '" + prompt + DOES_NOT_MATCH_PATTERN + expectedPromptPattern + "'" , prompt . matches ( expectedPromptPattern ) ) ; }
|
Asserts that 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 .
|
36,181
|
public void cookieEquals ( String cookieName , String expectedCookieValue ) { assertEquals ( "Cookie Value Mismatch" , expectedCookieValue , checkCookieEquals ( cookieName , expectedCookieValue , 0 , 0 ) ) ; }
|
Asserts that 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 .
|
36,182
|
public void cookieMatches ( String cookieName , String expectedCookiePattern ) { String cookie = checkCookieMatches ( cookieName , expectedCookiePattern , 0 , 0 ) ; assertTrue ( "Cookie Value Mismatch: cookie value of '" + cookie + DOES_NOT_MATCH_PATTERN + expectedCookiePattern + "'" , cookie . matches ( expectedCookiePattern ) ) ; }
|
Asserts that 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 .
|
36,183
|
public void clazz ( String expectedClass ) { String clazz = checkClazz ( expectedClass , 0 , 0 ) ; assertNotNull ( NO_ELEMENT_FOUND , clazz ) ; assertTrue ( "Class Mismatch: class of '" + clazz + DOES_NOT_CONTAIN + expectedClass + "'" , clazz . contains ( expectedClass ) ) ; }
|
Asserts that the element s class contains 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 .
|
36,184
|
public void attribute ( String expectedAttribute ) { Set < String > attributes = checkAttribute ( expectedAttribute , 0 , 0 ) ; assertNotNull ( NO_ELEMENT_FOUND , attributes ) ; assertTrue ( "Attribute not found: element attributes of '" + String . join ( "," , attributes ) + DOES_NOT_CONTAIN + expectedAttribute + "'" , attributes . contains ( expectedAttribute ) ) ; }
|
Asserts that the element contains 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 .
|
36,185
|
public void text ( String expectedText ) { String text = checkText ( expectedText , 0 , 0 ) ; assertNotNull ( NO_ELEMENT_FOUND , text ) ; assertTrue ( "Text not found: element text of '" + text + DOES_NOT_CONTAIN + expectedText + "'" , text . contains ( expectedText ) ) ; }
|
Asserts that the element s text contains 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 .
|
36,186
|
@ 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 ) ; assertTrue ( "Value not found: element value of '" + value + DOES_NOT_CONTAIN + expectedValue + "'" , value . contains ( expectedValue ) ) ; }
|
Asserts that the element s value contains 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 .
|
36,187
|
public void selectOption ( String expectedOption ) { String [ ] options = checkSelectOption ( expectedOption , 0 , 0 ) ; String reason = NO_ELEMENT_FOUND ; if ( options == null && getElement ( ) . is ( ) . present ( ) ) { reason = ELEMENT_NOT_SELECT ; } assertNotNull ( reason , options ) ; assertTrue ( "Option not found: element options of '" + String . join ( "," , options ) + DOES_NOT_CONTAIN + expectedOption + "'" , Arrays . asList ( options ) . contains ( expectedOption ) ) ; }
|
Asserts that the element s options contains 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 .
|
36,188
|
public void selectOptions ( int numOfOptions ) { int options = checkSelectOptions ( numOfOptions , 0 , 0 ) ; String reason = NO_ELEMENT_FOUND ; if ( options < 0 && getElement ( ) . is ( ) . present ( ) ) { reason = ELEMENT_NOT_SELECT ; } assertTrue ( reason , options >= 0 ) ; assertEquals ( "Number of options mismatch" , numOfOptions , options ) ; }
|
Asserts that the element has the expected number of 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 .
|
36,189
|
public void columns ( int numOfColumns ) { int columns = checkColumns ( numOfColumns , 0 , 0 ) ; String reason = NO_ELEMENT_FOUND ; if ( columns < 0 && getElement ( ) . is ( ) . present ( ) ) { reason = "Element not table" ; } assertTrue ( reason , columns >= 0 ) ; assertEquals ( "Number of columns mismatch" , numOfColumns , columns ) ; }
|
Asserts that the element has the expected number of columns . 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 .
|
36,190
|
public void rows ( int numOfRows ) { int rows = checkRows ( numOfRows , 0 , 0 ) ; String reason = NO_ELEMENT_FOUND ; if ( rows < 0 && getElement ( ) . is ( ) . present ( ) ) { reason = "Element not table" ; } assertTrue ( reason , rows >= 0 ) ; assertEquals ( "Number of rows mismatch" , numOfRows , rows ) ; }
|
Asserts that the element has the expected number of rows . 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 .
|
36,191
|
private void recordResult ( ITestResult result ) { Reporter reporter = ( Reporter ) result . getAttribute ( REPORTER ) ; String htmlFilename = "" ; String pdfFilename = "" ; if ( reporter != null ) { reporter . finalizeReporter ( result . getStatus ( ) - 1 ) ; htmlFilename = reporter . getFileName ( ) + ".html" ; if ( Property . generatePDF ( ) ) { pdfFilename = reporter . getFileName ( ) + ".pdf" ; } } String testName = getTestName ( result ) ; Browser browser = ( Browser ) result . getAttribute ( BROWSER ) ; if ( browser != null ) { org . testng . Reporter . log ( Success . values ( ) [ result . getStatus ( ) - 1 ] + OUTPUT_BREAK + browser . getDetails ( ) + OUTPUT_BREAK + LINK_START + getFolderName ( result ) + "/" + htmlFilename + LINK_MIDDLE + testName + " HTML Report" + LINK_END ) ; if ( ! pdfFilename . isEmpty ( ) ) { org . testng . Reporter . log ( OUTPUT_BREAK + LINK_START + getFolderName ( result ) + "/" + pdfFilename + LINK_MIDDLE + testName + " PDF" + LINK_END ) ; } org . testng . Reporter . log ( OUTPUT_BREAK + ( result . getEndMillis ( ) - result . getStartMillis ( ) ) / 1000 + TIME_UNIT ) ; } if ( Sauce . isSauce ( ) && result . getAttributeNames ( ) . contains ( SESSION_ID ) ) { String sessionId = result . getAttribute ( SESSION_ID ) . toString ( ) ; JsonObject json = new JsonObject ( ) ; json . addProperty ( "passed" , result . getStatus ( ) == 1 ) ; JsonArray tags = new JsonArray ( ) ; for ( String tag : result . getMethod ( ) . getGroups ( ) ) { tags . add ( tag ) ; } json . add ( "tags" , tags ) ; try { HTTP http = new HTTP ( null , "https://saucelabs.com/rest/v1/" + Sauce . getSauceUser ( ) + "/jobs/" , Sauce . getSauceUser ( ) , Sauce . getSauceKey ( ) ) ; http . put ( sessionId , new Request ( ) . setJsonPayload ( json ) , null ) ; } catch ( InvalidHubException e ) { log . error ( "Unable to connect to sauce, due to credential problems" ) ; } catch ( IOException e ) { log . error ( e ) ; } } }
|
Checks to see if the test execution was performed on SauceLabs or not . If it was this reaches out to Sauce in order to update the execution results
|
36,192
|
@ SuppressWarnings ( "unchecked" ) protected < T > List < T > getDialogListeners ( Class < T > listenerInterface ) { final Fragment targetFragment = getTargetFragment ( ) ; List < T > listeners = new ArrayList < T > ( 2 ) ; if ( targetFragment != null && listenerInterface . isAssignableFrom ( targetFragment . getClass ( ) ) ) { listeners . add ( ( T ) targetFragment ) ; } if ( getActivity ( ) != null && listenerInterface . isAssignableFrom ( getActivity ( ) . getClass ( ) ) ) { listeners . add ( ( T ) getActivity ( ) ) ; } return Collections . unmodifiableList ( listeners ) ; }
|
Utility method for acquiring all listeners of some type for current instance of DialogFragment
|
36,193
|
private void modifyButtonsBasedOnScrollableContent ( boolean scrollable ) { if ( getView ( ) == null ) { return ; } View vButtonDivider = getView ( ) . findViewById ( R . id . sdl_button_divider ) ; View vButtonsBottomSpace = getView ( ) . findViewById ( R . id . sdl_buttons_bottom_space ) ; View vDefaultButtons = getView ( ) . findViewById ( R . id . sdl_buttons_default ) ; View vStackedButtons = getView ( ) . findViewById ( R . id . sdl_buttons_stacked ) ; if ( vDefaultButtons . getVisibility ( ) == View . GONE && vStackedButtons . getVisibility ( ) == View . GONE ) { vButtonDivider . setVisibility ( View . GONE ) ; vButtonsBottomSpace . setVisibility ( View . GONE ) ; } else if ( scrollable ) { vButtonDivider . setVisibility ( View . VISIBLE ) ; vButtonsBottomSpace . setVisibility ( View . GONE ) ; } else { vButtonDivider . setVisibility ( View . GONE ) ; vButtonsBottomSpace . setVisibility ( View . VISIBLE ) ; } }
|
Button divider should be shown only if the content is scrollable .
|
36,194
|
private int resolveTheme ( ) { int theme = getTheme ( ) ; if ( theme != 0 ) { return theme ; } boolean useLightTheme = isActivityThemeLight ( ) ; Bundle args = getArguments ( ) ; if ( args != null ) { if ( args . getBoolean ( BaseDialogBuilder . ARG_USE_DARK_THEME ) ) { useLightTheme = false ; } else if ( args . getBoolean ( BaseDialogBuilder . ARG_USE_LIGHT_THEME ) ) { useLightTheme = true ; } } return useLightTheme ? R . style . SDL_Dialog : R . style . SDL_Dark_Dialog ; }
|
Resolves the theme to be used for the dialog .
|
36,195
|
private boolean isActivityThemeLight ( ) { try { TypedValue val = new TypedValue ( ) ; getActivity ( ) . getTheme ( ) . resolveAttribute ( R . attr . isLightTheme , val , true ) ; TypedArray styledAttributes = getActivity ( ) . obtainStyledAttributes ( val . data , new int [ ] { R . attr . isLightTheme } ) ; boolean lightTheme = styledAttributes . getBoolean ( 0 , false ) ; styledAttributes . recycle ( ) ; return lightTheme ; } catch ( RuntimeException e ) { return true ; } }
|
This method resolves the current theme declared in the manifest
|
36,196
|
public Long processIdentifier ( Object id ) { Objects . requireNonNull ( id , "Element identifier cannot be null" ) ; if ( id instanceof Long ) return ( Long ) id ; if ( id instanceof Number ) return ( ( Number ) id ) . longValue ( ) ; if ( id instanceof String ) return Long . valueOf ( ( String ) id ) ; throw new IllegalArgumentException ( String . format ( "Expected an id that is convertible to Long but received %s" , id . getClass ( ) ) ) ; }
|
Process the given identifier converting it to the correct type if necessary .
|
36,197
|
public String matchPredicateOperand ( String alias ) { Objects . requireNonNull ( alias , "alias cannot be null" ) ; return alias + "." + idFieldName ; }
|
Gets the MATCH WHERE predicate operand .
|
36,198
|
public void createIndex ( String label , String propertyName ) { Objects . requireNonNull ( label , "label cannot be null" ) ; Objects . requireNonNull ( propertyName , "propertyName cannot be null" ) ; Neo4JSession session = currentSession ( ) ; transaction . readWrite ( ) ; session . executeStatement ( new Statement ( "CREATE INDEX ON :`" + label + "`(" + propertyName + ")" ) ) ; }
|
Creates an index in the neo4j database .
|
36,199
|
private int getIndex ( int ind ) { int i = Arrays . binarySearchGreater ( index , ind , 0 , used ) ; if ( i < used && index [ i ] == ind ) return i ; int [ ] newIndex = index ; double [ ] newData = data ; if ( ++ used > data . length ) { int newLength = data . length != 0 ? data . length << 1 : 1 ; newLength = Math . min ( newLength , this . size ) ; newIndex = new int [ newLength ] ; newData = new double [ newLength ] ; System . arraycopy ( index , 0 , newIndex , 0 , i ) ; System . arraycopy ( data , 0 , newData , 0 , i ) ; } System . arraycopy ( index , i , newIndex , i + 1 , used - i - 1 ) ; System . arraycopy ( data , i , newData , i + 1 , used - i - 1 ) ; newIndex [ i ] = ind ; newData [ i ] = 0. ; index = newIndex ; data = newData ; return i ; }
|
Tries to find the index . If it is not found a reallocation is done and a new index is returned .
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.