idx
int64
0
41.2k
question
stringlengths
73
5.81k
target
stringlengths
5
918
15,900
protected void assertLegalRelativeAddition ( String relativePropertySourceName , PropertySource < ? > propertySource ) { String newPropertySourceName = propertySource . getName ( ) ; if ( relativePropertySourceName . equals ( newPropertySourceName ) ) { throw new IllegalArgumentException ( "PropertySource named '" + ne...
Ensure that the given property source is not being added relative to itself .
15,901
private void addAtIndex ( int index , PropertySource < ? > propertySource ) { removeIfPresent ( propertySource ) ; this . propertySourceList . add ( index , propertySource ) ; }
Add the given property source at a particular index in the list .
15,902
private int assertPresentAndGetIndex ( String name ) { int index = this . propertySourceList . indexOf ( PropertySource . named ( name ) ) ; if ( index == - 1 ) { throw new IllegalArgumentException ( "PropertySource named '" + name + "' does not exist" ) ; } return index ; }
Assert that the named property source is present and return its index .
15,903
public void fail ( ) { hasFailure = true ; long count = latch . getCount ( ) ; for ( int i = 0 ; i < count ; i ++ ) { latch . countDown ( ) ; } }
Countdown and fail - fast if the sub message is failed .
15,904
protected final void putInt16 ( int i16 ) { ensureCapacity ( position + 2 ) ; byte [ ] buf = buffer ; buf [ position ++ ] = ( byte ) ( i16 & 0xff ) ; buf [ position ++ ] = ( byte ) ( i16 >>> 8 ) ; }
Put 16 - bit integer in the buffer .
15,905
protected final void putInt32 ( long i32 ) { ensureCapacity ( position + 4 ) ; byte [ ] buf = buffer ; buf [ position ++ ] = ( byte ) ( i32 & 0xff ) ; buf [ position ++ ] = ( byte ) ( i32 >>> 8 ) ; buf [ position ++ ] = ( byte ) ( i32 >>> 16 ) ; buf [ position ++ ] = ( byte ) ( i32 >>> 24 ) ; }
Put 32 - bit integer in the buffer .
15,906
protected final void putString ( String s ) { ensureCapacity ( position + ( s . length ( ) * 2 ) + 1 ) ; System . arraycopy ( s . getBytes ( ) , 0 , buffer , position , s . length ( ) ) ; position += s . length ( ) ; buffer [ position ++ ] = 0 ; }
Put a string in the buffer .
15,907
public static final String collateCharset ( String charset ) { String [ ] output = StringUtils . split ( charset , "COLLATE" ) ; return output [ 0 ] . replace ( '\'' , ' ' ) . trim ( ) ; }
utf8 COLLATE utf8_general_ci
15,908
public void updateByQuery ( ESSyncConfig config , Map < String , Object > paramsTmp , Map < String , Object > esFieldData ) { if ( paramsTmp . isEmpty ( ) ) { return ; } ESMapping mapping = config . getEsMapping ( ) ; BoolQueryBuilder queryBuilder = QueryBuilders . boolQuery ( ) ; paramsTmp . forEach ( ( fieldName , va...
update by query
15,909
public static String getCharset ( final int id ) { Entry entry = getEntry ( id ) ; if ( entry != null ) { return entry . mysqlCharset ; } else { logger . warn ( "Unexpect mysql charset: " + id ) ; return null ; } }
Return defined charset name for mysql .
15,910
public static String getCollation ( final int id ) { Entry entry = getEntry ( id ) ; if ( entry != null ) { return entry . mysqlCollation ; } else { logger . warn ( "Unexpect mysql charset: " + id ) ; return null ; } }
Return defined collaction name for mysql .
15,911
public static String getJavaCharset ( final int id ) { Entry entry = getEntry ( id ) ; if ( entry != null ) { if ( entry . javaCharset != null ) { return entry . javaCharset ; } else { logger . warn ( "Unknown java charset for: id = " + id + ", name = " + entry . mysqlCharset + ", coll = " + entry . mysqlCollation ) ; ...
Return converted charset name for java .
15,912
public static HashMode getPartitionHashColumns ( String name , String pkHashConfigs ) { if ( StringUtils . isEmpty ( pkHashConfigs ) ) { return null ; } List < PartitionData > datas = partitionDatas . get ( pkHashConfigs ) ; for ( PartitionData data : datas ) { if ( data . simpleName != null ) { if ( data . simpleName ...
match return List not match return null
15,913
private final void decodeFields ( LogBuffer buffer , final int len ) { final int limit = buffer . limit ( ) ; buffer . limit ( len + buffer . position ( ) ) ; for ( int i = 0 ; i < columnCnt ; i ++ ) { ColumnInfo info = columnInfo [ i ] ; switch ( info . type ) { case MYSQL_TYPE_TINY_BLOB : case MYSQL_TYPE_BLOB : case ...
Decode field metadata by column types .
15,914
public LogEvent decode ( LogBuffer buffer , LogContext context ) throws IOException { final int limit = buffer . limit ( ) ; if ( limit >= FormatDescriptionLogEvent . LOG_EVENT_HEADER_LEN ) { LogHeader header = new LogHeader ( buffer , context . getFormatDescription ( ) ) ; final int len = header . getEventLen ( ) ; if...
Decoding an event from binary - log buffer .
15,915
public final int compareTo ( String fileName , final long position ) { final int val = this . fileName . compareTo ( fileName ) ; if ( val == 0 ) { return ( int ) ( this . position - position ) ; } return val ; }
Compares with the specified fileName and position .
15,916
public final LogBuffer duplicate ( final int pos , final int len ) { if ( pos + len > limit ) throw new IllegalArgumentException ( "limit excceed: " + ( pos + len ) ) ; final int off = origin + pos ; byte [ ] buf = Arrays . copyOfRange ( buffer , off , off + len ) ; return new LogBuffer ( buf , 0 , len ) ; }
Return n bytes in this buffer .
15,917
public final LogBuffer forward ( final int len ) { if ( position + len > origin + limit ) throw new IllegalArgumentException ( "limit excceed: " + ( position + len - origin ) ) ; this . position += len ; return this ; }
Forwards this buffer s position .
15,918
public final LogBuffer consume ( final int len ) { if ( limit > len ) { limit -= len ; origin += len ; position = origin ; return this ; } else if ( limit == len ) { limit = 0 ; origin = 0 ; position = 0 ; return this ; } else { throw new IllegalArgumentException ( "limit excceed: " + len ) ; } }
Consume this buffer moving origin and position .
15,919
public final int getInt8 ( final int pos ) { if ( pos >= limit || pos < 0 ) throw new IllegalArgumentException ( "limit excceed: " + pos ) ; return buffer [ origin + pos ] ; }
Return 8 - bit signed int from buffer .
15,920
public final int getUint8 ( final int pos ) { if ( pos >= limit || pos < 0 ) throw new IllegalArgumentException ( "limit excceed: " + pos ) ; return 0xff & buffer [ origin + pos ] ; }
Return 8 - bit unsigned int from buffer .
15,921
public final String getFixString ( final int pos , final int len , String charsetName ) { if ( pos + len > limit || pos < 0 ) throw new IllegalArgumentException ( "limit excceed: " + ( pos < 0 ? pos : ( pos + len ) ) ) ; final int from = origin + pos ; final int end = from + len ; byte [ ] buf = buffer ; int found = fr...
Return fix length string from buffer .
15,922
public final String getFixString ( final int len , String charsetName ) { if ( position + len > origin + limit ) throw new IllegalArgumentException ( "limit excceed: " + ( position + len - origin ) ) ; final int from = position ; final int end = from + len ; byte [ ] buf = buffer ; int found = from ; for ( ; ( found < ...
Return next fix length string from buffer .
15,923
public final String getString ( final int pos , String charsetName ) { if ( pos >= limit || pos < 0 ) throw new IllegalArgumentException ( "limit excceed: " + pos ) ; byte [ ] buf = buffer ; final int len = ( 0xff & buf [ origin + pos ] ) ; if ( pos + len + 1 > limit ) throw new IllegalArgumentException ( "limit exccee...
Return dynamic length string from buffer .
15,924
public final String getString ( String charsetName ) { if ( position >= origin + limit ) throw new IllegalArgumentException ( "limit excceed: " + position ) ; byte [ ] buf = buffer ; final int len = ( 0xff & buf [ position ] ) ; if ( position + len + 1 > origin + limit ) throw new IllegalArgumentException ( "limit excc...
Return next dynamic length string from buffer .
15,925
public final boolean nextOneRow ( BitSet columns , boolean after ) { final boolean hasOneRow = buffer . hasRemaining ( ) ; if ( hasOneRow ) { int column = 0 ; for ( int i = 0 ; i < columnLen ; i ++ ) if ( columns . get ( i ) ) { column ++ ; } if ( after && partial ) { partialBits . clear ( ) ; long valueOptions = buffe...
Extracting next row from packed buffer .
15,926
static int mysqlToJavaType ( int type , final int meta , boolean isBinary ) { int javaType ; if ( type == LogEvent . MYSQL_TYPE_STRING ) { if ( meta >= 256 ) { int byte0 = meta >> 8 ; if ( ( byte0 & 0x30 ) != 0x30 ) { type = byte0 | 0x30 ; } else { switch ( byte0 ) { case LogEvent . MYSQL_TYPE_SET : case LogEvent . MYS...
Maps the given MySQL type to the correct JDBC type .
15,927
protected void afterStartEventParser ( CanalEventParser eventParser ) { List < ClientIdentity > clientIdentitys = metaManager . listAllSubscribeInfo ( destination ) ; for ( ClientIdentity clientIdentity : clientIdentitys ) { subscribeChange ( clientIdentity ) ; } }
around event parser default impl
15,928
public long lastModified ( ) throws IOException { long lastModified = getFileForLastModifiedCheck ( ) . lastModified ( ) ; if ( lastModified == 0L ) { throw new FileNotFoundException ( getDescription ( ) + " cannot be resolved in the file system for resolving its last-modified timestamp" ) ; } return lastModified ; }
This implementation checks the timestamp of the underlying File if available .
15,929
public org . springframework . core . io . Resource createRelative ( String relativePath ) throws IOException { throw new FileNotFoundException ( "Cannot create a relative resource for " + getDescription ( ) ) ; }
This implementation throws a FileNotFoundException assuming that relative resources cannot be created for this resource .
15,930
public void setNameAliases ( Map < String , List < String > > aliases ) { this . nameAliases = new LinkedMultiValueMap < String , String > ( aliases ) ; }
Set name aliases .
15,931
public static long readUnsignedIntLittleEndian ( byte [ ] data , int index ) { long result = ( long ) ( data [ index ] & 0xFF ) | ( long ) ( ( data [ index + 1 ] & 0xFF ) << 8 ) | ( long ) ( ( data [ index + 2 ] & 0xFF ) << 16 ) | ( long ) ( ( data [ index + 3 ] & 0xFF ) << 24 ) ; return result ; }
Read 4 bytes in Little - endian byte order .
15,932
public synchronized String format ( final LogRecord record ) { buffer . setLength ( PREFIX . length ( ) ) ; buffer . append ( timestampFormatter . format ( new Date ( record . getMillis ( ) ) ) ) ; buffer . append ( ' ' ) ; buffer . append ( levelNumberToCommonsLevelName ( record . getLevel ( ) ) ) ; String [ ] parts =...
Format the given log record and return the formatted string .
15,933
public String getSeleniumScript ( String name ) { String rawFunction = readScript ( PREFIX + name ) ; return String . format ( "function() { return (%s).apply(null, arguments);}" , rawFunction ) ; }
Loads the named Selenium script and returns it wrapped in an anonymous function .
15,934
public static RegistrationRequest fromJson ( Map < String , Object > raw ) throws JsonException { Json json = new Json ( ) ; RegistrationRequest request = new RegistrationRequest ( ) ; if ( raw . get ( "name" ) instanceof String ) { request . name = ( String ) raw . get ( "name" ) ; } if ( raw . get ( "description" ) i...
Create an object from a registration request formatted as a json string .
15,935
public void validate ( ) throws GridConfigurationException { try { configuration . getHubHost ( ) ; configuration . getHubPort ( ) ; } catch ( RuntimeException e ) { throw new GridConfigurationException ( e . getMessage ( ) ) ; } }
Validate the current setting and throw a config exception is an invalid setup is detected .
15,936
public void forwardNewSessionRequestAndUpdateRegistry ( TestSession session ) throws NewSessionException { try ( NewSessionPayload payload = NewSessionPayload . create ( ImmutableMap . of ( "desiredCapabilities" , session . getRequestedCapabilities ( ) ) ) ) { StringBuilder json = new StringBuilder ( ) ; payload . writ...
Forward the new session request to the TestSession that has been assigned and parse the response to extract and return the external key assigned by the remote .
15,937
private void beforeSessionEvent ( ) throws NewSessionException { RemoteProxy p = session . getSlot ( ) . getProxy ( ) ; if ( p instanceof TestSessionListener ) { try { ( ( TestSessionListener ) p ) . beforeSession ( session ) ; } catch ( Exception e ) { log . severe ( "Error running the beforeSessionListener : " + e . ...
calls the TestSessionListener is the proxy for that node has one specified .
15,938
public void waitForSessionBound ( ) throws InterruptedException , TimeoutException { GridHubConfiguration configuration = getRegistry ( ) . getHub ( ) . getConfiguration ( ) ; Integer newSessionWaitTimeout = configuration . newSessionWaitTimeout != null ? configuration . newSessionWaitTimeout : 0 ; if ( newSessionWaitT...
wait for the registry to match the request with a TestSlot .
15,939
public static ExpectedCondition < Boolean > titleIs ( final String title ) { return new ExpectedCondition < Boolean > ( ) { private String currentTitle = "" ; public Boolean apply ( WebDriver driver ) { currentTitle = driver . getTitle ( ) ; return title . equals ( currentTitle ) ; } public String toString ( ) { return...
An expectation for checking the title of a page .
15,940
public static ExpectedCondition < Boolean > titleContains ( final String title ) { return new ExpectedCondition < Boolean > ( ) { private String currentTitle = "" ; public Boolean apply ( WebDriver driver ) { currentTitle = driver . getTitle ( ) ; return currentTitle != null && currentTitle . contains ( title ) ; } pub...
An expectation for checking that the title contains a case - sensitive substring
15,941
public static ExpectedCondition < Boolean > urlToBe ( final String url ) { return new ExpectedCondition < Boolean > ( ) { private String currentUrl = "" ; public Boolean apply ( WebDriver driver ) { currentUrl = driver . getCurrentUrl ( ) ; return currentUrl != null && currentUrl . equals ( url ) ; } public String toSt...
An expectation for the URL of the current page to be a specific url .
15,942
public static ExpectedCondition < Boolean > urlContains ( final String fraction ) { return new ExpectedCondition < Boolean > ( ) { private String currentUrl = "" ; public Boolean apply ( WebDriver driver ) { currentUrl = driver . getCurrentUrl ( ) ; return currentUrl != null && currentUrl . contains ( fraction ) ; } pu...
An expectation for the URL of the current page to contain specific text .
15,943
public static ExpectedCondition < Boolean > urlMatches ( final String regex ) { return new ExpectedCondition < Boolean > ( ) { private String currentUrl ; private Pattern pattern ; private Matcher matcher ; public Boolean apply ( WebDriver driver ) { currentUrl = driver . getCurrentUrl ( ) ; pattern = Pattern . compile...
Expectation for the URL to match a specific regular expression
15,944
public static ExpectedCondition < WebElement > presenceOfElementLocated ( final By locator ) { return new ExpectedCondition < WebElement > ( ) { public WebElement apply ( WebDriver driver ) { return driver . findElement ( locator ) ; } public String toString ( ) { return "presence of element located by: " + locator ; }...
An expectation for checking that an element is present on the DOM of a page . This does not necessarily mean that the element is visible .
15,945
public static ExpectedCondition < WebElement > visibilityOfElementLocated ( final By locator ) { return new ExpectedCondition < WebElement > ( ) { public WebElement apply ( WebDriver driver ) { try { return elementIfVisible ( driver . findElement ( locator ) ) ; } catch ( StaleElementReferenceException e ) { return nul...
An expectation for checking that an element is present on the DOM of a page and visible . Visibility means that the element is not only displayed but also has a height and width that is greater than 0 .
15,946
public static ExpectedCondition < WebElement > visibilityOf ( final WebElement element ) { return new ExpectedCondition < WebElement > ( ) { public WebElement apply ( WebDriver driver ) { return elementIfVisible ( element ) ; } public String toString ( ) { return "visibility of " + element ; } } ; }
An expectation for checking that an element known to be present on the DOM of a page is visible . Visibility means that the element is not only displayed but also has a height and width that is greater than 0 .
15,947
public static ExpectedCondition < List < WebElement > > presenceOfAllElementsLocatedBy ( final By locator ) { return new ExpectedCondition < List < WebElement > > ( ) { public List < WebElement > apply ( WebDriver driver ) { List < WebElement > elements = driver . findElements ( locator ) ; return elements . size ( ) >...
An expectation for checking that there is at least one element present on a web page .
15,948
public static ExpectedCondition < Boolean > textToBePresentInElement ( final WebElement element , final String text ) { return new ExpectedCondition < Boolean > ( ) { public Boolean apply ( WebDriver driver ) { try { String elementText = element . getText ( ) ; return elementText . contains ( text ) ; } catch ( StaleEl...
An expectation for checking if the given text is present in the specified element .
15,949
public static ExpectedCondition < Boolean > textToBePresentInElementLocated ( final By locator , final String text ) { return new ExpectedCondition < Boolean > ( ) { public Boolean apply ( WebDriver driver ) { try { String elementText = driver . findElement ( locator ) . getText ( ) ; return elementText . contains ( te...
An expectation for checking if the given text is present in the element that matches the given locator .
15,950
public static ExpectedCondition < Boolean > invisibilityOfElementLocated ( final By locator ) { return new ExpectedCondition < Boolean > ( ) { public Boolean apply ( WebDriver driver ) { try { return ! ( driver . findElement ( locator ) . isDisplayed ( ) ) ; } catch ( NoSuchElementException e ) { return true ; } catch ...
An expectation for checking that an element is either invisible or not present on the DOM .
15,951
public static ExpectedCondition < Boolean > invisibilityOfElementWithText ( final By locator , final String text ) { return new ExpectedCondition < Boolean > ( ) { public Boolean apply ( WebDriver driver ) { try { return ! driver . findElement ( locator ) . getText ( ) . equals ( text ) ; } catch ( NoSuchElementExcepti...
An expectation for checking that an element with text is either invisible or not present on the DOM .
15,952
public static ExpectedCondition < Boolean > stalenessOf ( final WebElement element ) { return new ExpectedCondition < Boolean > ( ) { public Boolean apply ( WebDriver ignored ) { try { element . isEnabled ( ) ; return false ; } catch ( StaleElementReferenceException expected ) { return true ; } } public String toString...
Wait until an element is no longer attached to the DOM .
15,953
public static < T > ExpectedCondition < T > refreshed ( final ExpectedCondition < T > condition ) { return new ExpectedCondition < T > ( ) { public T apply ( WebDriver driver ) { try { return condition . apply ( driver ) ; } catch ( StaleElementReferenceException e ) { return null ; } } public String toString ( ) { ret...
Wrapper for a condition which allows for elements to update by redrawing .
15,954
public static ExpectedCondition < Boolean > elementSelectionStateToBe ( final WebElement element , final boolean selected ) { return new ExpectedCondition < Boolean > ( ) { public Boolean apply ( WebDriver driver ) { return element . isSelected ( ) == selected ; } public String toString ( ) { return String . format ( "...
An expectation for checking if the given element is selected .
15,955
public static ExpectedCondition < Boolean > not ( final ExpectedCondition < ? > condition ) { return new ExpectedCondition < Boolean > ( ) { public Boolean apply ( WebDriver driver ) { Object result = condition . apply ( driver ) ; return result == null || result . equals ( Boolean . FALSE ) ; } public String toString ...
An expectation with the logical opposite condition of the given condition .
15,956
public static ExpectedCondition < Boolean > attributeToBe ( final By locator , final String attribute , final String value ) { return new ExpectedCondition < Boolean > ( ) { private String currentValue = null ; public Boolean apply ( WebDriver driver ) { WebElement element = driver . findElement ( locator ) ; currentVa...
An expectation for checking WebElement with given locator has attribute with a specific value
15,957
public static ExpectedCondition < Boolean > textToBe ( final By locator , final String value ) { return new ExpectedCondition < Boolean > ( ) { private String currentValue = null ; public Boolean apply ( WebDriver driver ) { try { currentValue = driver . findElement ( locator ) . getText ( ) ; return currentValue . equ...
An expectation for checking WebElement with given locator has specific text
15,958
public static ExpectedCondition < Boolean > textMatches ( final By locator , final Pattern pattern ) { return new ExpectedCondition < Boolean > ( ) { private String currentValue = null ; public Boolean apply ( WebDriver driver ) { try { currentValue = driver . findElement ( locator ) . getText ( ) ; return pattern . ma...
An expectation for checking WebElement with given locator has text with a value as a part of it
15,959
public static ExpectedCondition < List < WebElement > > numberOfElementsToBeMoreThan ( final By locator , final Integer number ) { return new ExpectedCondition < List < WebElement > > ( ) { private Integer currentNumber = 0 ; public List < WebElement > apply ( WebDriver webDriver ) { List < WebElement > elements = webD...
An expectation for checking number of WebElements with given locator being more than defined number
15,960
public static ExpectedCondition < Boolean > attributeContains ( final WebElement element , final String attribute , final String value ) { return new ExpectedCondition < Boolean > ( ) { private String currentValue = null ; public Boolean apply ( WebDriver driver ) { return getAttributeOrCssValue ( element , attribute )...
An expectation for checking WebElement with given locator has attribute which contains specific value
15,961
public static ExpectedCondition < Boolean > attributeToBeNotEmpty ( final WebElement element , final String attribute ) { return driver -> getAttributeOrCssValue ( element , attribute ) . isPresent ( ) ; }
An expectation for checking WebElement any non empty value for given attribute
15,962
public static ExpectedCondition < WebElement > presenceOfNestedElementLocatedBy ( final WebElement element , final By childLocator ) { return new ExpectedCondition < WebElement > ( ) { public WebElement apply ( WebDriver webDriver ) { return element . findElement ( childLocator ) ; } public String toString ( ) { return...
An expectation for checking child WebElement as a part of parent element to be present
15,963
public static ExpectedCondition < Boolean > invisibilityOfAllElements ( final List < WebElement > elements ) { return new ExpectedCondition < Boolean > ( ) { public Boolean apply ( WebDriver webDriver ) { return elements . stream ( ) . allMatch ( ExpectedConditions :: isInvisible ) ; } public String toString ( ) { retu...
An expectation for checking all elements from given list to be invisible
15,964
public static ExpectedCondition < Boolean > invisibilityOf ( final WebElement element ) { return new ExpectedCondition < Boolean > ( ) { public Boolean apply ( WebDriver webDriver ) { return isInvisible ( element ) ; } public String toString ( ) { return "invisibility of " + element ; } } ; }
An expectation for checking the element to be invisible
15,965
public static ExpectedCondition < Boolean > or ( final ExpectedCondition < ? > ... conditions ) { return new ExpectedCondition < Boolean > ( ) { public Boolean apply ( WebDriver driver ) { RuntimeException lastException = null ; for ( ExpectedCondition < ? > condition : conditions ) { try { Object result = condition . ...
An expectation with the logical or condition of the given list of conditions .
15,966
public static ExpectedCondition < Boolean > and ( final ExpectedCondition < ? > ... conditions ) { return new ExpectedCondition < Boolean > ( ) { public Boolean apply ( WebDriver driver ) { for ( ExpectedCondition < ? > condition : conditions ) { Object result = condition . apply ( driver ) ; if ( result instanceof Boo...
An expectation with the logical and condition of the given list of conditions .
15,967
public static ExpectedCondition < Boolean > javaScriptThrowsNoExceptions ( final String javaScript ) { return new ExpectedCondition < Boolean > ( ) { public Boolean apply ( WebDriver driver ) { try { ( ( JavascriptExecutor ) driver ) . executeScript ( javaScript ) ; return true ; } catch ( WebDriverException e ) { retu...
An expectation to check if js executable .
15,968
public static ExpectedCondition < Object > jsReturnsValue ( final String javaScript ) { return new ExpectedCondition < Object > ( ) { public Object apply ( WebDriver driver ) { try { Object value = ( ( JavascriptExecutor ) driver ) . executeScript ( javaScript ) ; if ( value instanceof List ) { return ( ( List < ? > ) ...
An expectation for String value from javascript
15,969
public Map < String , String > getAlert ( ) { HashMap < String , String > toReturn = new HashMap < > ( ) ; toReturn . put ( "text" , getAlertText ( ) ) ; return Collections . unmodifiableMap ( toReturn ) ; }
Used for serialising . Some of the drivers return the alert text like this .
15,970
@ SuppressWarnings ( "JavaDoc" ) public static String escape ( String toEscape ) { if ( toEscape . contains ( "\"" ) && toEscape . contains ( "'" ) ) { boolean quoteIsLast = false ; if ( toEscape . lastIndexOf ( "\"" ) == toEscape . length ( ) - 1 ) { quoteIsLast = true ; } String [ ] substringsWithoutQuotes = toEscape...
Convert strings with both quotes and ticks into a valid xpath component
15,971
@ SuppressWarnings ( "unchecked" ) public static < T extends RemoteProxy > T getNewInstance ( RegistrationRequest request , GridRegistry registry ) { try { String proxyClass = request . getConfiguration ( ) . proxy ; if ( proxyClass == null ) { log . fine ( "No proxy class. Using default" ) ; proxyClass = BaseRemotePro...
Takes a registration request and return the RemoteProxy associated to it . It can be any class extending RemoteProxy .
15,972
public RemoteProxy remove ( RemoteProxy proxy ) { for ( RemoteProxy p : proxies ) { if ( p . equals ( proxy ) ) { proxies . remove ( p ) ; return p ; } } throw new IllegalStateException ( "Did not contain proxy" + proxy ) ; }
Removes the specified instance from the proxySet
15,973
public RemoteWebDriverBuilder oneOf ( Capabilities maybeThis , Capabilities ... orOneOfThese ) { options . clear ( ) ; addAlternative ( maybeThis ) ; for ( Capabilities anOrOneOfThese : orOneOfThese ) { addAlternative ( anOrOneOfThese ) ; } return this ; }
Clears the current set of alternative browsers and instead sets the list of possible choices to the arguments given to this method .
15,974
public RemoteWebDriverBuilder addAlternative ( Capabilities options ) { Map < String , Object > serialized = validate ( Objects . requireNonNull ( options ) ) ; this . options . add ( serialized ) ; return this ; }
Add to the list of possible configurations that might be asked for . It is possible to ask for more than one type of browser per session . For example perhaps you have an extension that is available for two different kinds of browser and you d like to test it ) .
15,975
public String runHTMLSuite ( String browser , String startURL , String suiteURL , File outputFile , long timeoutInSeconds , String userExtensions ) throws IOException { File parent = outputFile . getParentFile ( ) ; if ( parent != null && ! parent . exists ( ) ) { parent . mkdirs ( ) ; } if ( outputFile . exists ( ) &&...
Launches a single HTML Selenium test suite .
15,976
public String newWindow ( WindowType type ) { Response response = execute ( "SAFARI_NEW_WINDOW" , ImmutableMap . of ( "newTab" , type == WindowType . TAB ) ) ; return ( String ) response . getValue ( ) ; }
Open either a new tab or window depending on what is requested and return the window handle without switching to it .
15,977
private String getConsoleIconPath ( DesiredCapabilities cap ) { String name = consoleIconName ( cap ) ; String path = "org/openqa/grid/images/" ; InputStream in = Thread . currentThread ( ) . getContextClassLoader ( ) . getResourceAsStream ( path + name + ".png" ) ; if ( in == null ) { return null ; } return "/grid/res...
get the icon representing the browser for the grid . If the icon cannot be located returns null .
15,978
private String getConfigInfo ( ) { StringBuilder builder = new StringBuilder ( ) ; builder . append ( "<div id='hub-config-container'>" ) ; GridHubConfiguration config = getRegistry ( ) . getHub ( ) . getConfiguration ( ) ; builder . append ( "<div id='hub-config-content'>" ) ; builder . append ( "<b>Config for the hub...
retracing how the hub config was built to help debugging .
15,979
private String getVerboseConfig ( ) { StringBuilder builder = new StringBuilder ( ) ; GridHubConfiguration config = getRegistry ( ) . getHub ( ) . getConfiguration ( ) ; builder . append ( "<div id='verbose-config-container'>" ) ; builder . append ( "<a id='verbose-config-view-toggle' href='#'>View Verbose</a>" ) ; bui...
Displays more detailed configuration
15,980
public TestSession getNewSession ( Map < String , Object > requestedCapability ) { if ( down ) { return null ; } return super . getNewSession ( requestedCapability ) ; }
overwrites the session allocation to discard the proxy that are down .
15,981
public HttpResponse encode ( Supplier < HttpResponse > factory , Response response ) { int status = response . getStatus ( ) == ErrorCodes . SUCCESS ? HTTP_OK : HTTP_INTERNAL_ERROR ; byte [ ] data = json . toJson ( getValueToEncode ( response ) ) . getBytes ( UTF_8 ) ; HttpResponse httpResponse = factory . get ( ) ; ht...
Encodes the given response as a HTTP response message . This method is guaranteed not to throw .
15,982
public PropertySetting propertySetting ( PropertySetting setter ) { PropertySetting previous = this . setter ; this . setter = Objects . requireNonNull ( setter ) ; return previous ; }
Change how property setting is done . It s polite to set the value back once done processing .
15,983
public Actions keyUp ( CharSequence key ) { if ( isBuildingActions ( ) ) { action . addAction ( new KeyUpAction ( jsonKeyboard , jsonMouse , asKeys ( key ) ) ) ; } return addKeyAction ( key , codePoint -> tick ( defaultKeyboard . createKeyUp ( codePoint ) ) ) ; }
Performs a modifier key release . Releasing a non - depressed modifier key will yield undefined behaviour .
15,984
public Actions release ( ) { if ( isBuildingActions ( ) ) { action . addAction ( new ButtonReleaseAction ( jsonMouse , null ) ) ; } return tick ( defaultMouse . createPointerUp ( Button . LEFT . asArg ( ) ) ) ; }
Releases the depressed left mouse button at the current mouse location .
15,985
public Actions doubleClick ( ) { if ( isBuildingActions ( ) ) { action . addAction ( new DoubleClickAction ( jsonMouse , null ) ) ; } return clickInTicks ( LEFT ) . clickInTicks ( LEFT ) ; }
Performs a double - click at the current mouse location .
15,986
public Actions moveToElement ( WebElement target ) { if ( isBuildingActions ( ) ) { action . addAction ( new MoveMouseAction ( jsonMouse , ( Locatable ) target ) ) ; } return moveInTicks ( target , 0 , 0 ) ; }
Moves the mouse to the middle of the element . The element is scrolled into view and its location is calculated using getBoundingClientRect .
15,987
public Actions moveToElement ( WebElement target , int xOffset , int yOffset ) { if ( isBuildingActions ( ) ) { action . addAction ( new MoveToOffsetAction ( jsonMouse , ( Locatable ) target , xOffset , yOffset ) ) ; } LOG . info ( "When using the W3C Action commands, offsets are from the center of element" ) ; return ...
Moves the mouse to an offset from the top - left corner of the element . The element is scrolled into view and its location is calculated using getBoundingClientRect .
15,988
public Actions contextClick ( WebElement target ) { if ( isBuildingActions ( ) ) { action . addAction ( new ContextClickAction ( jsonMouse , ( Locatable ) target ) ) ; } return moveInTicks ( target , 0 , 0 ) . clickInTicks ( RIGHT ) ; }
Performs a context - click at middle of the given element . First performs a mouseMove to the location of the element .
15,989
public Actions contextClick ( ) { if ( isBuildingActions ( ) ) { action . addAction ( new ContextClickAction ( jsonMouse , null ) ) ; } return clickInTicks ( RIGHT ) ; }
Performs a context - click at the current mouse location .
15,990
public Actions dragAndDrop ( WebElement source , WebElement target ) { if ( isBuildingActions ( ) ) { action . addAction ( new ClickAndHoldAction ( jsonMouse , ( Locatable ) source ) ) ; action . addAction ( new MoveMouseAction ( jsonMouse , ( Locatable ) target ) ) ; action . addAction ( new ButtonReleaseAction ( json...
A convenience method that performs click - and - hold at the location of the source element moves to the location of the target element then releases the mouse .
15,991
public Actions dragAndDropBy ( WebElement source , int xOffset , int yOffset ) { if ( isBuildingActions ( ) ) { action . addAction ( new ClickAndHoldAction ( jsonMouse , ( Locatable ) source ) ) ; action . addAction ( new MoveToOffsetAction ( jsonMouse , null , xOffset , yOffset ) ) ; action . addAction ( new ButtonRel...
A convenience method that performs click - and - hold at the location of the source element moves by a given offset then releases the mouse .
15,992
public Actions pause ( long pause ) { if ( isBuildingActions ( ) ) { action . addAction ( new PauseAction ( pause ) ) ; } return tick ( new Pause ( defaultMouse , Duration . ofMillis ( pause ) ) ) ; }
Performs a pause .
15,993
public void wait ( String message , long timeoutInMilliseconds , long intervalInMilliseconds ) { long start = System . currentTimeMillis ( ) ; long end = start + timeoutInMilliseconds ; while ( System . currentTimeMillis ( ) < end ) { if ( until ( ) ) return ; try { Thread . sleep ( intervalInMilliseconds ) ; } catch (...
Wait until the until condition returns true or time runs out .
15,994
public String getQueryParameter ( String name ) { Iterable < String > allParams = getQueryParameters ( name ) ; if ( allParams == null ) { return null ; } Iterator < String > iterator = allParams . iterator ( ) ; return iterator . hasNext ( ) ? iterator . next ( ) : null ; }
Get a query parameter . The implementation will take care of decoding from the percent encoding .
15,995
public HttpRequest addQueryParameter ( String name , String value ) { queryParameters . put ( Objects . requireNonNull ( name , "Name must be set" ) , Objects . requireNonNull ( value , "Value must be set" ) ) ; return this ; }
Set a query parameter adding to existing values if present . The implementation will ensure that the name and value are properly encoded .
15,996
public CrossDomainRpc loadRpc ( HttpServletRequest request ) throws IOException { Charset encoding ; try { String enc = request . getCharacterEncoding ( ) ; encoding = Charset . forName ( enc ) ; } catch ( IllegalArgumentException | NullPointerException e ) { encoding = UTF_8 ; } try ( InputStream in = request . getInp...
Parses the request for a CrossDomainRpc .
15,997
private static Capabilities dropCapabilities ( Capabilities capabilities ) { if ( capabilities == null ) { return new ImmutableCapabilities ( ) ; } MutableCapabilities caps ; if ( isLegacy ( capabilities ) ) { final Set < String > toRemove = Sets . newHashSet ( BINARY , PROFILE ) ; caps = new MutableCapabilities ( Maps...
Drops capabilities that we shouldn t send over the wire .
15,998
public File createTempDir ( String prefix , String suffix ) { try { File file = File . createTempFile ( prefix , suffix , baseDir ) ; file . delete ( ) ; File dir = new File ( file . getAbsolutePath ( ) ) ; if ( ! dir . mkdirs ( ) ) { throw new WebDriverException ( "Cannot create profile directory at " + dir . getAbsol...
Create a temporary directory and track it for deletion .
15,999
public void deleteTempDir ( File file ) { if ( ! shouldReap ( ) ) { return ; } if ( temporaryFiles . remove ( file ) ) { FileHandler . delete ( file ) ; } }
Delete a temporary directory that we were responsible for creating .