idx
int64
0
165k
question
stringlengths
73
4.15k
target
stringlengths
5
918
len_question
int64
21
890
len_target
int64
3
255
35,900
private String getStringValue ( Object o ) { if ( o instanceof String ) { return ( String ) o ; } else if ( o instanceof NodeArray ) { NodeArray array = ( NodeArray ) o ; switch ( array . size ( ) ) { case 0 : return null ; case 1 : { return getStringValue ( array . get ( 0 ) ) ; } default : return getStringValue ( arr...
Returns the string value for the object
132
7
35,901
private String getStringValue ( Node node ) { switch ( node . getNodeType ( ) ) { case Node . ATTRIBUTE_NODE : case Node . TEXT_NODE : return node . getNodeValue ( ) ; default : { try { Transformer transformer = TRANSFORMER_FACTORY . newTransformer ( ) ; StringWriter buffer = new StringWriter ( ) ; transformer . setOut...
Returns the string value for the node
148
7
35,902
private String getStringValue ( NodeArray nodes ) { StringBuilder stringBuilder = new StringBuilder ( ) ; // If all we have is just a bunch of nodes and the user wants a string // we'll use a parent element called <string> to have a valid XML document stringBuilder . append ( "<string>" ) ; for ( Node node : nodes ) { ...
Returns the string value for the node array
109
8
35,903
@ SuppressWarnings ( { "unchecked" , "rawtypes" } ) private void populateMap ( Map map , Node node ) { Map . Entry entry = getMapEntry ( node ) ; if ( entry != null ) { map . put ( entry . getKey ( ) , entry . getValue ( ) ) ; } }
Given the node populates the map
71
7
35,904
public void addAttribute ( final String _name , final String _value ) { this . attributes . put ( _name , new XmlNode ( ) { { this . name = _name ; this . value = _value ; this . valid = true ; this . type = XmlNode . ATTRIBUTE_NODE ; } } ) ; }
Adds the attribute
74
3
35,905
public static Object getPrimitiveValue ( String value , PrimitiveCategory primitiveCategory ) { if ( value != null ) { try { switch ( primitiveCategory ) { case BOOLEAN : return Boolean . valueOf ( value ) ; case BYTE : return Byte . valueOf ( value ) ; case DOUBLE : return Double . valueOf ( value ) ; case FLOAT : ret...
Converts the string value to the java object for the given primitive category
164
14
35,906
public static ObjectInspector getStandardJavaObjectInspectorFromTypeInfo ( TypeInfo typeInfo , XmlProcessor xmlProcessor ) { switch ( typeInfo . getCategory ( ) ) { case PRIMITIVE : { return PrimitiveObjectInspectorFactory . getPrimitiveJavaObjectInspector ( ( ( PrimitiveTypeInfo ) typeInfo ) . getPrimitiveCategory ( )...
Returns the standard java object inspector
487
6
35,907
public static StructObjectInspector getStandardStructObjectInspector ( List < String > structFieldNames , List < ObjectInspector > structFieldObjectInspectors , XmlProcessor xmlProcessor ) { return new XmlStructObjectInspector ( structFieldNames , structFieldObjectInspectors , xmlProcessor ) ; }
Returns the struct object inspector
73
5
35,908
public void transform ( XmlNode node , StringBuilder builder ) { switch ( node . getType ( ) ) { case XmlNode . ELEMENT_NODE : { builder . append ( "<" ) ; builder . append ( node . getName ( ) ) ; for ( XmlNode attribute : node . getAttributes ( ) . values ( ) ) { transform ( attribute , builder ) ; } builder . append...
Transforms the XML node into the string
239
8
35,909
public void setVideoURI ( Uri uri , Map < String , String > headers ) { mUri = uri ; mHeaders = headers ; mSeekWhenPrepared = 0 ; openVideo ( ) ; requestLayout ( ) ; invalidate ( ) ; }
Sets video URI using specific headers .
57
8
35,910
public static StartupSettings fromJSONFile ( File jsonFile ) throws JSONException , FileNotFoundException , IOException { // Read the file to a String. StringBuffer buffer = new StringBuffer ( ) ; try ( BufferedReader br = new BufferedReader ( new FileReader ( jsonFile ) ) ) { String line ; while ( ( line = br . readLi...
Parse the settings for the gossip service from a JSON file .
456
13
35,911
protected void sendMembershipList ( LocalGossipMember me , List < LocalGossipMember > memberList ) { GossipService . LOGGER . debug ( "Send sendMembershipList() is called." ) ; me . setHeartbeat ( System . currentTimeMillis ( ) ) ; LocalGossipMember member = selectPartner ( memberList ) ; if ( member == null ) { return...
Performs the sending of the membership list after we have incremented our own heartbeat .
386
17
35,912
public void run ( ) { for ( LocalGossipMember member : members . keySet ( ) ) { if ( member != me ) { member . startTimeoutTimer ( ) ; } } try { passiveGossipThread = passiveGossipThreadClass . getConstructor ( GossipManager . class ) . newInstance ( this ) ; gossipThreadExecutor . execute ( passiveGossipThread ) ; act...
Starts the client . Specifically start the various cycles for this protocol . Start the gossip thread and start the receiver thread .
245
24
35,913
public void shutdown ( ) { gossipServiceRunning . set ( false ) ; gossipThreadExecutor . shutdown ( ) ; if ( passiveGossipThread != null ) { passiveGossipThread . shutdown ( ) ; } if ( activeGossipThread != null ) { activeGossipThread . shutdown ( ) ; } try { boolean result = gossipThreadExecutor . awaitTermination ( 1...
Shutdown the gossip service .
130
6
35,914
private boolean isObjectHasValue ( Object targetObj ) { for ( Map . Entry < String , String > entry : cellMapping . entrySet ( ) ) { if ( ! StringUtils . equalsIgnoreCase ( HEADER_KEY , entry . getKey ( ) ) ) { if ( StringUtils . isNotBlank ( getPropertyValue ( targetObj , entry . getValue ( ) ) ) ) { return true ; } }...
To check generic object of T has a minimum one value assigned or not
98
14
35,915
private void readSheet ( StylesTable styles , ReadOnlySharedStringsTable sharedStringsTable , InputStream sheetInputStream ) throws IOException , ParserConfigurationException , SAXException { SAXParserFactory saxFactory = SAXParserFactory . newInstance ( ) ; XMLReader sheetParser = saxFactory . newSAXParser ( ) . getXM...
Parses the content of one sheet using the specified styles and shared - strings tables .
134
18
35,916
private static String getProgramProperty ( String property ) { if ( System . getProperty ( property ) != null ) { return System . getProperty ( property ) . trim ( ) ; } Properties prop = new Properties ( ) ; try ( InputStream input = new FileInputStream ( SELENIFIED ) ) { prop . load ( input ) ; } catch ( IOException ...
Retrieves the specified program property . if it exists from the system properties that is returned overridding all other values . Otherwise if it exists from the properties file that is returned otherwise null is returned
123
39
35,917
public static boolean generatePDF ( ) { String generatePDF = getProgramProperty ( GENERATE_PDF ) ; if ( generatePDF == null ) { return false ; } if ( "" . equals ( generatePDF ) ) { return true ; } return "true" . equalsIgnoreCase ( generatePDF ) ; }
Determines if we are supposed to generate a pdf of the results or not
65
16
35,918
public static boolean packageResults ( ) { String packageResults = getProgramProperty ( PACKAGE_RESULTS ) ; if ( packageResults == null ) { return false ; } if ( "" . equals ( packageResults ) ) { return true ; } return "true" . equalsIgnoreCase ( packageResults ) ; }
Determines if we are supposed to zip up the results or not
64
14
35,919
public static String getProxy ( ) throws InvalidProxyException { String proxy = getProgramProperty ( PROXY ) ; if ( proxy == null ) { throw new InvalidProxyException ( PROXY_ISNT_SET ) ; } String [ ] proxyParts = proxy . split ( ":" ) ; if ( proxyParts . length != 2 ) { throw new InvalidProxyException ( "Proxy '" + pro...
Retrieves the proxy property if it is set . This could be to something local or in the cloud . Provide the protocol address and port
164
28
35,920
public static String getAppURL ( String clazz , ITestContext context ) throws InvalidHTTPException { String appURL = checkAppURL ( null , ( String ) context . getAttribute ( clazz + APP_URL ) , "The provided app via test case setup '" ) ; Properties prop = new Properties ( ) ; try ( InputStream input = new FileInputStr...
Obtains the application under test as a URL . If the site was provided as a system property that value will override whatever was set in the particular test suite . If no site was set null will be returned which will causes the tests to error out
211
49
35,921
private static String checkAppURL ( String originalAppURL , String newAppURL , String s ) { if ( newAppURL != null && ! "" . equals ( newAppURL ) ) { if ( ! newAppURL . toLowerCase ( ) . startsWith ( "http" ) && ! newAppURL . toLowerCase ( ) . startsWith ( "file" ) ) { newAppURL = "http://" + newAppURL ; } try { new UR...
A helper method to getAppURL which checks the provided URL and if it is valid overrides the initially provided one .
150
24
35,922
public static String getBrowser ( ) { String browser = getProgramProperty ( BROWSER ) ; if ( browser == null || "" . equals ( browser ) ) { browser = Browser . BrowserName . HTMLUNIT . toString ( ) ; } return browser ; }
Retrieves the browser property if it is set . This can be a single browser name or browser details . If it is not set HTMLUnit will be returned as the default browser to use
55
38
35,923
public static boolean runHeadless ( ) { String headless = getProgramProperty ( HEADLESS ) ; if ( headless == null ) { return false ; } if ( "" . equals ( headless ) ) { return true ; } return "true" . equalsIgnoreCase ( headless ) ; }
Determines if the headless parameter was set to have the browser run in headless mode . This only can be used for Chrome and Firefox .
63
30
35,924
public static String getOptions ( ) throws InvalidBrowserOptionsException { String options = getProgramProperty ( OPTIONS ) ; if ( options == null || "" . equals ( options ) ) { throw new InvalidBrowserOptionsException ( "Browser options aren't set" ) ; } return options ; }
Retrieves the set options
59
6
35,925
public void present ( double seconds ) { try { double timeTook = elementPresent ( seconds ) ; checkPresent ( seconds , timeTook ) ; } catch ( TimeoutException e ) { checkPresent ( seconds , seconds ) ; } }
Waits for the element to be present . The provided wait time will be used and if the element isn t present after that time it will fail and log the issue with a screenshot for traceability and added debugging support .
50
44
35,926
public void notPresent ( double seconds ) { double end = System . currentTimeMillis ( ) + ( seconds * 1000 ) ; try { WebDriverWait wait = new WebDriverWait ( element . getDriver ( ) , ( long ) seconds , DEFAULT_POLLING_INTERVAL ) ; wait . until ( ExpectedConditions . not ( ExpectedConditions . presenceOfAllElementsLoca...
Waits for the element to not be present . The provided wait time will be used and if the element isn t present after that time it will fail and log the issue with a screenshot for traceability and added debugging support .
163
45
35,927
public void displayed ( 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 ( ExpectedCond...
Waits for the element to be displayed . The provided wait time will be used and if the element isn t present after that time it will fail and log the issue with a screenshot for traceability and added debugging support .
167
44
35,928
public void notDisplayed ( 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 ( ExpectedC...
Waits for the element to not be displayed . The provided wait time will be used and if the element isn t present after that time it will fail and log the issue with a screenshot for traceability and added debugging support .
172
45
35,929
public void checked ( double seconds ) { double end = System . currentTimeMillis ( ) + ( seconds * 1000 ) ; try { elementPresent ( seconds ) ; while ( ! element . is ( ) . checked ( ) && System . currentTimeMillis ( ) < end ) ; double timeTook = Math . min ( ( seconds * 1000 ) - ( end - System . currentTimeMillis ( ) )...
Waits for the element to be checked . The provided wait time will be used and if the element isn t present after that time it will fail and log the issue with a screenshot for traceability and added debugging support .
126
44
35,930
public void editable ( double seconds ) { double end = System . currentTimeMillis ( ) + ( seconds * 1000 ) ; try { elementPresent ( seconds ) ; while ( ! element . is ( ) . editable ( ) && System . currentTimeMillis ( ) < end ) ; double timeTook = Math . min ( ( seconds * 1000 ) - ( end - System . currentTimeMillis ( )...
Waits for the element to be editable . The provided wait time will be used and if the element isn t present after that time it will fail and log the issue with a screenshot for traceability and added debugging support . If the element isn t an input this will constitute a failure same as it not being editable .
126
65
35,931
public void enabled ( 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 ( ExpectedCondit...
Waits for the element to be enabled . The provided wait time will be used and if the element isn t present after that time it will fail and log the issue with a screenshot for traceability and added debugging support .
166
44
35,932
public void notEnabled ( 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 ( ExpectedCon...
Waits for the element to not be enabled . The provided wait time will be used and if the element isn t present after that time it will fail and log the issue with a screenshot for traceability and added debugging support .
177
45
35,933
private Response call ( Method method , String endpoint , Request params , File inputFile ) { StringBuilder action = new StringBuilder ( ) ; action . append ( "Making <i>" ) ; action . append ( method . toString ( ) ) ; action . append ( "</i> call to <i>" ) ; action . append ( http . getServiceBaseUrl ( ) ) . append (...
Performs an http call and writes the call and response information to the output file
414
16
35,934
public void setupProxy ( ) throws InvalidProxyException { // are we running through a proxy if ( Property . isProxySet ( ) ) { // set the proxy information Proxy proxy = new Proxy ( ) ; proxy . setHttpProxy ( Property . getProxy ( ) ) ; desiredCapabilities . setCapability ( CapabilityType . PROXY , proxy ) ; } }
Obtains the set system values for the proxy and adds them to the desired desiredCapabilities
76
18
35,935
public WebDriver setupDriver ( ) throws InvalidBrowserException { WebDriver driver ; // check the browser switch ( browser . getName ( ) ) { case HTMLUNIT : System . getProperties ( ) . put ( "org.apache.commons.logging.simplelog.defaultlog" , "fatal" ) ; java . util . logging . Logger . getLogger ( "com.gargoylesoftwa...
this creates the webdriver object which will be used to interact with for all browser web tests
631
18
35,936
public void addExtraCapabilities ( DesiredCapabilities extraCapabilities ) { if ( extraCapabilities != null && browser . getName ( ) != BrowserName . NONE ) { desiredCapabilities = desiredCapabilities . merge ( extraCapabilities ) ; } }
If additional capabilities are provided in the test case add them in
55
12
35,937
protected static void setAppURL ( Selenified clazz , ITestContext context , String siteURL ) { context . setAttribute ( clazz . getClass ( ) . getName ( ) + APP_URL , siteURL ) ; }
Sets the URL of the application under test . If the site was provided as a system property this method ignores the passed in value and uses the system property .
50
32
35,938
private String getVersion ( String clazz , ITestContext context ) { return ( String ) context . getAttribute ( clazz + "Version" ) ; }
Obtains the version of the current test suite being executed . If no version was set null will be returned
33
21
35,939
protected static void setVersion ( Selenified clazz , ITestContext context , String version ) { context . setAttribute ( clazz . getClass ( ) . getName ( ) + "Version" , version ) ; }
Sets the version of the current test suite being executed .
47
12
35,940
private String getAuthor ( String clazz , ITestContext context ) { return ( String ) context . getAttribute ( clazz + "Author" ) ; }
Obtains the author of the current test suite being executed . If no author was set null will be returned
33
21
35,941
protected static void setAuthor ( Selenified clazz , ITestContext context , String author ) { context . setAttribute ( clazz . getClass ( ) . getName ( ) + "Author" , author ) ; }
Sets the author of the current test suite being executed .
47
12
35,942
private static Map < String , Object > getExtraHeaders ( String clazz , ITestContext context ) { return ( Map < String , Object > ) context . getAttribute ( clazz + "Headers" ) ; }
Obtains the additional headers of the current test suite being executed . If no additional headers were set null will be returned
47
23
35,943
protected static void addAdditionalDesiredCapabilities ( Selenified clazz , ITestContext context , String capabilityName , Object capabilityValue ) { DesiredCapabilities desiredCapabilities = new DesiredCapabilities ( ) ; if ( context . getAttributeNames ( ) . contains ( clazz . getClass ( ) . getName ( ) + DESIRED_CAP...
Sets any additional capabilities desired for the browsers . Things like enabling javascript accepting insecure certs . etc can all be added here on a per test class basis .
163
31
35,944
private static DesiredCapabilities getAdditionalDesiredCapabilities ( String clazz , ITestContext context ) { return ( DesiredCapabilities ) context . getAttribute ( clazz + DESIRED_CAPABILITIES ) ; }
Retrieves the additional desired capabilities set by the current class for the browsers
47
15
35,945
private static String getServiceUserCredential ( String clazz , ITestContext context ) { if ( System . getenv ( "SERVICES_USER" ) != null ) { return System . getenv ( "SERVICES_USER" ) ; } if ( context . getAttribute ( clazz + SERVICES_USER ) != null ) { return ( String ) context . getAttribute ( clazz + SERVICES_USER ...
Obtains the web services username provided for the current test suite being executed . Anything passed in from the command line will first be taken to override any other values . Next values being set in the classes will be checked for . If neither of these are set an empty string will be returned
98
56
35,946
private static String getServicePassCredential ( String clazz , ITestContext context ) { if ( System . getenv ( "SERVICES_PASS" ) != null ) { return System . getenv ( "SERVICES_PASS" ) ; } if ( context . getAttribute ( clazz + SERVICES_PASS ) != null ) { return ( String ) context . getAttribute ( clazz + SERVICES_PASS ...
Obtains the web services password provided for the current test suite being executed . Anything passed in from the command line will first be taken to override any other values . Next values being set in the classes will be checked for . If neither of these are set an empty string will be returned
98
56
35,947
private void loadInitialPage ( App app , String url , Reporter reporter ) { String startingPage = "The initial url of <i>" ; String act = "Opening new browser and loading up initial url" ; String expected = startingPage + url + "</i> will successfully load" ; if ( app != null ) { try { app . getDriver ( ) . get ( url )...
Loads the initial app specified by the url and ensures the app loads successfully
214
15
35,948
protected void finish ( ) { Reporter reporter = this . reporterThreadLocal . get ( ) ; assertEquals ( "Detailed results found at: " + reporter . getFileName ( ) , "0 errors" , Integer . toString ( reporter . getFails ( ) ) + ERRORS_CHECK ) ; }
Concludes each test case . This should be run as the last time of each
65
16
35,949
private void setupScreenSize ( App app ) { String screensize = app . getBrowser ( ) . getScreensize ( ) ; if ( screensize != null ) { if ( screensize . matches ( "(\\d+)x(\\d+)" ) ) { int width = Integer . parseInt ( screensize . split ( "x" ) [ 0 ] ) ; int height = Integer . parseInt ( screensize . split ( "x" ) [ 1 ]...
Sets up the initial size of the browser . Checks for the passed in parameter of screensize . If set to width x height sets the browser to that size ; if set to maximum maximizes the browser .
156
42
35,950
private void init ( WebDriver driver , Reporter reporter ) { this . driver = driver ; this . reporter = reporter ; App app = null ; if ( reporter != null ) { app = reporter . getApp ( ) ; } is = new Is ( this ) ; get = new Get ( app , driver , this ) ; verifyState = new VerifyState ( this , reporter ) ; assertState = n...
A private method to finish setting up each element
238
9
35,951
private String prettyOutputStart ( String initialString ) { initialString += Reporter . ordinal ( match + 1 ) + " element with <i>" + type . toString ( ) + "</i> of <i>" + locator + "</i>" ; if ( parent != null ) { initialString = parent . prettyOutputStart ( initialString + " and parent of " ) ; } return initialString...
Builds the nicely HTML formatted output of the element by retrieving parent element information
87
15
35,952
public By defineByElement ( ) { // consider adding strengthening By byElement = null ; switch ( type ) { // determine which locator type we are interested in case XPATH : byElement = By . xpath ( locator ) ; break ; case ID : byElement = By . id ( locator ) ; break ; case NAME : byElement = By . name ( locator ) ; brea...
Determines Selenium s By object using Webdriver
184
11
35,953
public WebElement getWebElement ( ) { List < WebElement > elements = getWebElements ( ) ; if ( elements . size ( ) > match ) { return elements . get ( match ) ; } String reason = this . prettyOutputStart ( ) + " was not located on the page" ; if ( ! elements . isEmpty ( ) ) { reason += ", but " + elements . size ( ) + ...
Retrieves the identified matching web element using Webdriver . Use this sparingly only when the action you want to perform on the element isn t available as commands from it won t be checked logged caught or screenshotted .
113
45
35,954
public List < WebElement > getWebElements ( ) { if ( parent != null ) { return parent . getWebElement ( ) . findElements ( defineByElement ( ) ) ; } return driver . findElements ( defineByElement ( ) ) ; }
Retrieves all matching web elements using Webdriver . Use this sparingly only when the action you want to perform on the element isn t available as commands from it won t be checked logged caught or screenshotted .
56
44
35,955
public Element findChild ( Element child ) { return new Element ( child . getDriver ( ) , reporter , child . getType ( ) , child . getLocator ( ) , child . getMatch ( ) , this ) ; }
Searches for a child element within the element and creates and returns this new child element
48
18
35,956
private boolean isNotInput ( String action , String expected , String extra ) { // wait for element to be displayed if ( ! is . input ( ) ) { reporter . fail ( action , expected , extra + prettyOutput ( ) + NOT_AN_INPUT ) ; // indicates element not an input return true ; } return false ; }
Determines if the element is an input .
70
10
35,957
private boolean isSelect ( String action , String expected ) { // wait for element to be displayed if ( ! is . select ( ) ) { reporter . fail ( action , expected , Element . CANT_SELECT + prettyOutput ( ) + NOT_A_SELECT ) ; // indicates element not an input return false ; } return true ; }
Determines if the element is a select .
70
10
35,958
private boolean isNotPresentDisplayedEnabled ( String action , String expected , String extra ) { // wait for element to be present if ( isNotPresent ( action , expected , extra ) ) { return true ; } // wait for element to be displayed if ( isNotDisplayed ( action , expected , extra ) ) { return true ; } // wait for el...
Determines if something is present displayed and enabled . This returns true if all three are true otherwise it returns false
90
23
35,959
private boolean isNotPresentEnabledInput ( String action , String expected ) { // wait for element to be present if ( isNotPresent ( action , expected , Element . CANT_TYPE ) ) { return true ; } // wait for element to be enabled return isNotEnabled ( action , expected , Element . CANT_TYPE ) || isNotInput ( action , ex...
Determines if something is present enabled and an input . This returns true if all three are true otherwise it returns false
86
24
35,960
private boolean isNotPresentDisplayedEnabledInput ( String action , String expected , String extra ) { // wait for element to be present if ( isNotPresent ( action , expected , extra ) ) { return true ; } // wait for element to be displayed if ( isNotDisplayed ( action , expected , extra ) ) { return true ; } // wait f...
Determines if something is present displayed enabled and an input . This returns true if all four are true otherwise it returns false
102
25
35,961
private boolean isNotPresentDisplayedEnabledSelect ( String action , String expected ) { // wait for element to be present if ( isNotPresent ( action , expected , Element . CANT_SELECT ) ) { return true ; } // wait for element to be displayed if ( isNotDisplayed ( action , expected , Element . CANT_SELECT ) ) { return ...
Determines if something is present displayed enabled and a select . This returns true if all four are true otherwise it returns false
112
25
35,962
public void click ( ) { String cantClick = "Unable to click " ; String action = "Clicking " + prettyOutput ( ) ; String expected = prettyOutputStart ( ) + " is present, displayed, and enabled to be clicked" ; try { if ( isNotPresentDisplayedEnabled ( action , expected , cantClick ) ) { return ; } WebElement webElement ...
Clicks on the element but only if the element is present displayed and enabled . If those conditions are not met the click action will be logged but skipped and the test will continue .
160
36
35,963
public void hover ( ) { String cantHover = "Unable to hover over " ; String action = "Hovering over " + prettyOutput ( ) ; String expected = prettyOutputStart ( ) + " is present, and displayed to be hovered over" ; try { // wait for element to be present if ( isNotPresent ( action , expected , cantHover ) ) { return ; ...
Hovers over the element but only if the element is present and displayed . If those conditions are not met the hover action will be logged but skipped and the test will continue .
218
35
35,964
public void focus ( ) { String cantFocus = "Unable to focus on " ; String action = "Focusing on " + prettyOutput ( ) ; String expected = prettyOutputStart ( ) + " is present, displayed, and enabled to be focused" ; try { if ( isNotPresentDisplayedEnabledInput ( action , expected , cantFocus ) ) { return ; } WebElement ...
Focuses on the element but only if the element is present displayed enabled and an input . If those conditions are not met the focus action will be logged but skipped and the test will continue .
175
39
35,965
public void type ( String text ) { String action = "Typing text '" + text + IN + prettyOutput ( ) ; String expected = prettyOutputStart ( ) + " is present, displayed, and enabled to have text " + text + " typed in" ; boolean warning = false ; try { if ( isNotPresentEnabledInput ( action , expected ) ) { return ; } if (...
Type the supplied text into the element but only if the element is present enabled and an input . If those conditions are not met the type action will be logged but skipped and the test will continue . If the element is not displayed a warning will be written in the log to indicate this is not a normal action as could ...
242
69
35,966
public void clear ( ) { String cantClear = "Unable to clear " ; String action = "Clearing text in " + prettyOutput ( ) ; String expected = prettyOutputStart ( ) + " is present, displayed, and enabled to have text cleared" ; try { if ( isNotPresentDisplayedEnabledInput ( action , expected , cantClear ) ) { return ; } We...
Clears text from the element but only if the element is present displayed enabled and an input . If those conditions are not met the clear action will be logged but skipped and the test will continue .
166
39
35,967
public void select ( int index ) { String action = SELECTING + index + " in " + prettyOutput ( ) ; String expected = prettyOutputStart ( ) + PRESENT_DISPLAYED_AND_ENABLED + index + SELECTED ; try { if ( isNotPresentDisplayedEnabledSelect ( action , expected ) ) { return ; } String [ ] options = get . selectOptions ( ) ...
Selects the Nth option from the element starting from 0 but only if the element is present displayed enabled and an input . If those conditions are not met the select action will be logged but skipped and the test will continue .
256
45
35,968
public void selectOption ( String option ) { String action = SELECTING + option + " in " + prettyOutput ( ) ; String expected = prettyOutputStart ( ) + PRESENT_DISPLAYED_AND_ENABLED + option + SELECTED ; try { if ( isNotPresentDisplayedEnabledSelect ( action , expected ) ) { return ; } // ensure the option exists if ( ...
Selects the option from the dropdown matching the provided value but only if the element is present displayed enabled and an input . If those conditions are not met the select action will be logged but skipped and the test will continue .
307
45
35,969
public void selectValue ( String value ) { String action = SELECTING + value + " in " + prettyOutput ( ) ; String expected = prettyOutputStart ( ) + PRESENT_DISPLAYED_AND_ENABLED + value + SELECTED ; try { if ( isNotPresentDisplayedEnabledSelect ( action , expected ) ) { return ; } // ensure the value exists if ( ! Arr...
Selects the value from the dropdown matching the provided value but only if the element is present displayed enabled and an input . If those conditions are not met the select action will be logged but skipped and the test will continue .
305
45
35,970
private void isScrolledTo ( String action , String expected ) { WebElement webElement = getWebElement ( ) ; long elementPosition = webElement . getLocation ( ) . getY ( ) ; JavascriptExecutor js = ( JavascriptExecutor ) driver ; int scrollHeight = ( ( Number ) js . executeScript ( "return document.documentElement.scrol...
Determines if the element scrolled towards is now currently displayed on the screen
220
16
35,971
public void scrollTo ( ) { String action = "Scrolling screen to " + prettyOutput ( ) ; String expected = prettyOutputStart ( ) + " is now within the current viewport" ; try { // wait for element to be present if ( isNotPresent ( action , expected , CANT_SCROLL ) ) { return ; } // perform the move action WebElement webE...
Scrolls the page to the element making it displayed on the current viewport but only if the element is present . If that condition is not met the scroll action will be logged but skipped and the test will continue .
138
43
35,972
public void scrollTo ( long position ) { String action = "Scrolling screen to " + position + " pixels above " + prettyOutput ( ) ; String expected = prettyOutputStart ( ) + " is now within the current viewport" ; try { // wait for element to be present if ( isNotPresent ( action , expected , CANT_SCROLL ) ) { return ; ...
Scrolls the page to the element leaving X pixels at the top of the viewport above it making it displayed on the current viewport but only if the element is present . If that condition is not met the scroll action will be logged but skipped and the test will continue .
190
55
35,973
public void draw ( List < Point < Integer , Integer > > points ) { if ( points . isEmpty ( ) ) { reporter . fail ( "Drawing object in " + prettyOutput ( ) , "Drew object in " + prettyOutput ( ) , "Unable to draw in " + prettyOutput ( ) + " as no points were supplied" ) ; return ; } StringBuilder pointString = new Strin...
Simulates moving the mouse around while the cursor is pressed . Can be used for drawing on canvases or swiping on certain elements . Note this is not supported in HTMLUNIT
471
36
35,974
public void selectFrame ( ) { String cantSelect = "Unable to focus on frame " ; String action = "Focusing on frame " + prettyOutput ( ) ; String expected = "Frame " + prettyOutput ( ) + " is present, displayed, and focused" ; try { // wait for element to be present if ( isNotPresent ( action , expected , cantSelect ) )...
Selects the frame represented by the element but only if the element is present and displayed . If these conditions are not met the move action will be logged but skipped and the test will continue .
208
38
35,975
private String getScreenshot ( ) { WebElement webElement = getWebElement ( ) ; String imageLink = "<b><font class='fail'>No Image Preview</font></b>" ; // capture an image of it try { imageLink = reporter . captureEntirePageScreenshot ( ) ; File image = new File ( reporter . getDirectory ( ) , imageLink . split ( "\"" ...
Captures an image of the element and returns the html friendly link of it for use in the logging file . If there is a problem capturing the image an error message is returned instead .
265
37
35,976
public String selectedOption ( ) { if ( isNotPresentSelect ( ) ) { return null ; } WebElement webElement = element . getWebElement ( ) ; Select dropdown = new Select ( webElement ) ; WebElement option = dropdown . getFirstSelectedOption ( ) ; return option . getText ( ) ; }
Retrieves the selected option for the element . If the element isn t present or a select a null value will be returned .
69
26
35,977
public String selectedValue ( ) { if ( isNotPresentSelect ( ) ) { return null ; } WebElement webElement = element . getWebElement ( ) ; Select dropdown = new Select ( webElement ) ; WebElement option = dropdown . getFirstSelectedOption ( ) ; return option . getAttribute ( VALUE ) ; }
Retrieves the selected value for the element . If the element isn t present or a select a null value will be returned .
71
26
35,978
@ SuppressWarnings ( "squid:S1168" ) public String [ ] selectedValues ( ) { if ( isNotPresentSelect ( ) ) { return null ; // returning an empty array could be confused with no values selected } WebElement webElement = element . getWebElement ( ) ; Select dropdown = new Select ( webElement ) ; List < WebElement > option...
Retrieves the selected values for the element . If the element isn t present or a select a null value will be returned .
154
26
35,979
public String text ( ) { if ( ! element . is ( ) . present ( ) ) { return null ; } WebElement webElement = element . getWebElement ( ) ; return webElement . getText ( ) ; }
Retrieves the text of the element . If the element isn t present a null value will be returned .
47
22
35,980
public String value ( ) { if ( ! element . is ( ) . present ( ) || ! element . is ( ) . input ( ) ) { return null ; } WebElement webElement = element . getWebElement ( ) ; return webElement . getAttribute ( VALUE ) ; }
Retrieves the value of the element . If the element isn t present or isn t an input a null value will be returned .
60
27
35,981
public String css ( String attribute ) { if ( ! element . is ( ) . present ( ) ) { return null ; } try { WebElement webElement = element . getWebElement ( ) ; return webElement . getCssValue ( attribute ) ; } catch ( NoSuchMethodError | Exception e ) { log . warn ( e ) ; return null ; } }
Retrieves the provided css attribute of the element . If the element isn t present the css attribute doesn t exist or the attributes can t be accessed a null value will be returned .
78
39
35,982
@ SuppressWarnings ( "unchecked" ) public Map < String , String > allAttributes ( ) { if ( ! element . is ( ) . present ( ) ) { return null ; } try { WebElement webElement = element . getWebElement ( ) ; JavascriptExecutor js = ( JavascriptExecutor ) driver ; return ( Map < String , String > ) js . executeScript ( "var...
Retrieves all attributes of the element . If the element isn t present or the attributes can t be accessed a null value will be returned .
168
29
35,983
public Object eval ( String javascriptFunction ) { if ( ! element . is ( ) . present ( ) ) { return null ; } try { WebElement webElement = element . getWebElement ( ) ; JavascriptExecutor js = ( JavascriptExecutor ) driver ; return js . executeScript ( javascriptFunction , webElement ) ; } catch ( NoSuchMethodError | E...
Executes a provided script on the element and returns the output of that script . If the element doesn t exist or there is an error executing this script a null value will be returned .
91
37
35,984
public int numOfSelectOptions ( ) { if ( isNotPresentSelect ( ) ) { return - 1 ; } WebElement webElement = element . getWebElement ( ) ; Select dropdown = new Select ( webElement ) ; List < WebElement > options = dropdown . getOptions ( ) ; return options . size ( ) ; }
Retrieves the number of select options in the element . If the element isn t present or a select the returned response will be negative 1 .
71
29
35,985
@ SuppressWarnings ( "squid:S1168" ) public String [ ] selectOptions ( ) { if ( isNotPresentSelect ( ) ) { return null ; // returning an empty array could be confused with no options available } WebElement webElement = element . getWebElement ( ) ; Select dropdown = new Select ( webElement ) ; List < WebElement > optio...
Retrieves the select options in the element . If the element isn t present or a select a null value will be returned .
149
26
35,986
@ SuppressWarnings ( "squid:S1168" ) public Element tableRows ( ) { if ( ! element . is ( ) . present ( ) ) { return null ; // returning an empty array could be confused with no rows } if ( ! element . is ( ) . table ( ) ) { return null ; // returning an empty array could be confused with no rows } return element . fin...
Retrieves the rows in the element . If the element isn t present or a table a null value will be returned . The rows will be returned in one element and they can be iterated through or selecting using the setMatch method
106
47
35,987
public int numOfTableColumns ( ) { Element rows = tableRows ( ) ; if ( rows == null ) { return - 1 ; } Element thCells = rows . findChild ( app . newElement ( Locator . TAGNAME , "th" ) ) ; Element tdCells = rows . findChild ( app . newElement ( Locator . TAGNAME , "td" ) ) ; return thCells . get ( ) . matchCount ( ) +...
Retrieves the number of columns in the element . If the element isn t present or a table the returned response will be negative one
113
27
35,988
@ SuppressWarnings ( "squid:S1168" ) public Element tableRow ( int rowNum ) { Element rows = tableRows ( ) ; if ( rows == null ) { return null ; } if ( numOfTableRows ( ) < rowNum ) { return null ; } return rows . get ( rowNum ) ; }
Retrieves a specific row from the element . If the element isn t present or a table or doesn t have that many rows a null value will be returned .
74
33
35,989
public Element tableCell ( int rowNum , int colNum ) { Element row = tableRow ( rowNum ) ; if ( row == null || numOfTableColumns ( ) < colNum ) { return null ; } Element thCells = row . findChild ( app . newElement ( Locator . TAGNAME , "th" ) ) ; Element tdCells = row . findChild ( app . newElement ( Locator . TAGNAME...
Retrieves a specific cell from the element . If the element isn t present or a table or the row and cell combination doesn t exist a null value will be returned .
159
35
35,990
public Map < String , Object > getHeaders ( ) { Map < String , Object > map = new HashMap <> ( ) ; map . put ( "Content-length" , "0" ) ; map . put ( CONTENT_TYPE , contentType ) ; map . put ( "Accept" , "application/json" ) ; for ( Map . Entry < String , Object > entry : extraHeaders . entrySet ( ) ) { map . put ( ent...
Builds the headers to be passed in the HTTP call
118
11
35,991
public Response get ( String service , Request request ) throws IOException { return call ( Method . GET , service , request , null ) ; }
A basic http get call
29
5
35,992
public Response post ( String service , Request request , File file ) throws IOException { if ( file != null ) { this . contentType = MULTIPART + BOUNDARY ; } return call ( Method . POST , service , request , file ) ; }
A basic http post call
54
5
35,993
public Response put ( String service , Request request , File file ) throws IOException { if ( file != null ) { this . contentType = MULTIPART + BOUNDARY ; } return call ( Method . PUT , service , request , file ) ; }
A basic http put call
55
5
35,994
public Response delete ( String service , Request request , File file ) throws IOException { if ( file != null ) { this . contentType = MULTIPART + BOUNDARY ; } return call ( Method . DELETE , service , request , file ) ; }
A basic http delete call
56
5
35,995
public String getRequestParams ( Request request ) { StringBuilder params = new StringBuilder ( ) ; if ( request != null && request . getUrlParams ( ) != null ) { params . append ( "?" ) ; for ( String key : request . getUrlParams ( ) . keySet ( ) ) { params . append ( key ) ; params . append ( "=" ) ; params . append ...
Returns a string representation of the parameters able to be appended to the url
142
15
35,996
private void setupHeaders ( HttpURLConnection connection ) { for ( Map . Entry < String , Object > entry : getHeaders ( ) . entrySet ( ) ) { connection . setRequestProperty ( entry . getKey ( ) , String . valueOf ( entry . getValue ( ) ) ) ; } connection . setDoOutput ( true ) ; connection . setDoInput ( true ) ; conne...
Setups up the header and basic connection information
105
9
35,997
private Response call ( Method method , String service , Request request , File file ) throws IOException { URL url = new URL ( this . serviceBaseUrl + service + getRequestParams ( request ) ) ; HttpURLConnection connection = getConnection ( url ) ; connection . setRequestMethod ( method . toString ( ) ) ; setupHeaders...
A basic generic http call
339
5
35,998
private HttpURLConnection getConnection ( URL url ) throws IOException { Proxy proxy = Proxy . NO_PROXY ; if ( Property . isProxySet ( ) ) { SocketAddress addr = new InetSocketAddress ( Property . getProxyHost ( ) , Property . getProxyPort ( ) ) ; proxy = new Proxy ( Proxy . Type . HTTP , addr ) ; } return ( HttpURLCon...
Opens the URL connection and if a proxy is provided uses the proxy to establish the connection
94
18
35,999
@ SuppressWarnings ( { "squid:S3776" , "squid:S2093" } ) private Response getResponse ( HttpURLConnection connection ) { int status ; Map headers ; try { status = connection . getResponseCode ( ) ; headers = connection . getHeaderFields ( ) ; } catch ( IOException e ) { log . error ( e ) ; return null ; } JsonObject ob...
Extracts the response data from the open http connection
444
11