How to use execute method of org.openqa.selenium.remote.RemoteWebElement class

Best Selenium code snippet using org.openqa.selenium.remote.RemoteWebElement.execute

Source:pureElement.java Github

copy

Full Screen

...316 this.centerOnScreen(); // Method to put object in center of the screen if partially or not visible317 return this.pureElementMethodCall( "getScreenshotAs", (Object) outputType );318 }319 // ************************************************************************************************************************ 320 // AndroidElement [0] = public org.openqa.selenium.remote.Response io.appium.java_client.android.AndroidElement.execute(java.lang.String,java.util.Map)321 // IOSElement [0] = public org.openqa.selenium.remote.Response io.appium.java_client.ios.IOSElement.execute(java.lang.String,java.util.Map)322 // MobileElement [1] = public org.openqa.selenium.remote.Response io.appium.java_client.MobileElement.execute(java.lang.String,java.util.Map)323 public org.openqa.selenium.remote.Response execute( java.lang.String execute, java.util.Map<?,?> map ){324 this.refresh();325 this.centerOnScreen(); // Method to put object in center of the screen if partially or not visible326 pureDriverDetails myDriver = pureDrivers.getCurrentDriverDetails();327 //328 Class<?>[] myClasses = new Class[2];329 myClasses[ 0 ] = java.lang.String.class;330 myClasses[ 1 ] = java.util.Map.class;331 //332 Object[] myTrueParam = new Object[2];333 myTrueParam[ 0 ] = (Object)execute;334 myTrueParam[ 1 ] = (Object)map;335 //336 return (org.openqa.selenium.remote.Response)pureCore.callMethod(337 this.theElement, myDriver.elementClass, "execute", myClasses, "pureElement.execute", myTrueParam );338 }339 // ************************************************************************************************************************ 340 // AndroidElement [1] = public org.openqa.selenium.remote.Response io.appium.java_client.android.AndroidElement.execute(java.lang.String)341 // IOSElement [1] = public org.openqa.selenium.remote.Response io.appium.java_client.ios.IOSElement.execute(java.lang.String)342 // MobileElement [0] = public org.openqa.selenium.remote.Response io.appium.java_client.MobileElement.execute(java.lang.String)343 public org.openqa.selenium.remote.Response execute( java.lang.String execute ){344 this.refresh();345 this.centerOnScreen(); // Method to put object in center of the screen if partially or not visible346 pureDriverDetails myDriver = pureDrivers.getCurrentDriverDetails();347 return (org.openqa.selenium.remote.Response)pureCore.callMethod(348 this.theElement, myDriver.elementClass, "execute", java.lang.String.class, "pureElement.execute", execute );349 }350 351 // ************************************************************************************************************************ 352 // AndroidElement [3] = public org.openqa.selenium.WebElement io.appium.java_client.android.AndroidElement.findElement(java.lang.String,java.lang.String)353 // IOSElement [2] = public org.openqa.selenium.WebElement io.appium.java_client.ios.IOSElement.findElement(java.lang.String,java.lang.String)354 // MobileElement [3] = public org.openqa.selenium.WebElement io.appium.java_client.MobileElement.findElement(java.lang.String,java.lang.String)355 public pureElement findElement( String method, String path ){356 this.refresh(); // Method to detect, update and centre the object on screen if existing.357 pureDriverDetails myDriver = pureDrivers.getCurrentDriverDetails();358 //359 Class<?>[] myClasses = new Class[2];360 myClasses[ 0 ] = java.lang.String.class;361 myClasses[ 1 ] = java.lang.String.class;362 //363 Object[] myTrueParam = new Object[2];364 myTrueParam[ 0 ] = (Object)method;365 myTrueParam[ 1 ] = (Object)path;366 //367 Object SourceObject = (Object)pureCore.callMethod( this.theElement, myDriver.elementClass, "findElement", myClasses, "pureElement.findElement", myTrueParam );368 if ( SourceObject != null ) {369 int elemMethod = pureCore.MethodFromStringLocator( method );370 pureElement newPureElement = new pureElement( "The Name", "The Type", elemMethod, path, pureCore.defRefreshMode, this );371 newPureElement.theElement = SourceObject;372 newPureElement.refrehCode = "0xFFFFFFFF";373 return newPureElement;374 }else {375 return null;376 } 377 }378 379 // ************************************************************************************************************************ 380 // Internal optimisation for following findElement methods.381 private pureElement intFindElementXXX( String MethodName, int elementMethod, String Description ) {382 this.refresh();383 Object SourceObject = (Object) this.pureElementMethodCall( MethodName, (Object)Description );384 if ( SourceObject != null ) {385 pureElement newPureElement = new pureElement( "The Name", "The Type", elementMethod, Description, pureCore.defRefreshMode, this );386 newPureElement.theElement = SourceObject;387 newPureElement.refrehCode = "0xFFFFFFFF";388 return newPureElement;389 }else {390 return (pureElement)null;391 } 392 } 393 394 // ************************************************************************************************************************ 395 // AndroidElement [4] = public org.openqa.selenium.WebElement io.appium.java_client.android.AndroidElement.findElementByLinkText(java.lang.String) throws org.openqa.selenium.WebDriverException396 // IOSElement [4] = public org.openqa.selenium.WebElement io.appium.java_client.ios.IOSElement.findElementByLinkText(java.lang.String) throws org.openqa.selenium.WebDriverException397 // MobileElement [7] = public org.openqa.selenium.WebElement io.appium.java_client.MobileElement.findElementByLinkText(java.lang.String) throws org.openqa.selenium.WebDriverException398 public pureElement findElementByLinkText( String Description ){399 return this.intFindElementXXX( "findElementByLinkText", pureCore.elementMethod.linkText, Description );400 }401 // ************************************************************************************************************************ 402 // AndroidElement [5] = public org.openqa.selenium.WebElement io.appium.java_client.android.AndroidElement.findElementByPartialLinkText(java.lang.String) throws org.openqa.selenium.WebDriverException403 // IOSElement [5] = public org.openqa.selenium.WebElement io.appium.java_client.ios.IOSElement.findElementByPartialLinkText(java.lang.String) throws org.openqa.selenium.WebDriverException404 // MobileElement [8] = public org.openqa.selenium.WebElement io.appium.java_client.MobileElement.findElementByPartialLinkText(java.lang.String) throws org.openqa.selenium.WebDriverException405 public pureElement findElementByPartialLinkText( String Description ){406 return this.intFindElementXXX( "findElementByPartialLinkText", pureCore.elementMethod.partialLinkText, Description );407 }408 409 // ************************************************************************************************************************ 410 // AndroidElement [6] = public org.openqa.selenium.WebElement io.appium.java_client.android.AndroidElement.findElementByTagName(java.lang.String)411 // IOSElement [6] = public org.openqa.selenium.WebElement io.appium.java_client.ios.IOSElement.findElementByTagName(java.lang.String)412 // MobileElement [9] = public org.openqa.selenium.WebElement io.appium.java_client.MobileElement.findElementByTagName(java.lang.String)413 public pureElement findElementByTagName( String Description ){414 return this.intFindElementXXX( "findElementByTagName", pureCore.elementMethod.tagNamei, Description );415 }416 417 // ************************************************************************************************************************ 418 // AndroidElement [7] = public org.openqa.selenium.WebElement io.appium.java_client.android.AndroidElement.findElementByName(java.lang.String)419 // IOSElement [7] = public org.openqa.selenium.WebElement io.appium.java_client.ios.IOSElement.findElementByName(java.lang.String)420 // MobileElement [10] = public org.openqa.selenium.WebElement io.appium.java_client.MobileElement.findElementByName(java.lang.String)421 public pureElement findElementByName( String Description ){422 return this.intFindElementXXX( "findElementByName", pureCore.elementMethod.name, Description );423 }424 425 // ************************************************************************************************************************ 426 // AndroidElement [8] = public org.openqa.selenium.WebElement io.appium.java_client.android.AndroidElement.findElementByClassName(java.lang.String)427 // IOSElement [8] = public org.openqa.selenium.WebElement io.appium.java_client.ios.IOSElement.findElementByClassName(java.lang.String)428 // MobileElement [11] = public org.openqa.selenium.WebElement io.appium.java_client.MobileElement.findElementByClassName(java.lang.String)429 public pureElement findElementByClassName( String Description ){430 return this.intFindElementXXX( "findElementByClassName", pureCore.elementMethod.className, Description );431 }432 433 // ************************************************************************************************************************ 434 // AndroidElement [9] = public org.openqa.selenium.WebElement io.appium.java_client.android.AndroidElement.findElementByCssSelector(java.lang.String) throws org.openqa.selenium.WebDriverException435 // IOSElement [9] = public org.openqa.selenium.WebElement io.appium.java_client.ios.IOSElement.findElementByCssSelector(java.lang.String) throws org.openqa.selenium.WebDriverException436 // MobileElement [12] = public org.openqa.selenium.WebElement io.appium.java_client.MobileElement.findElementByCssSelector(java.lang.String) throws org.openqa.selenium.WebDriverException437 public pureElement findElementByCssSelector( String Description ){438 return this.intFindElementXXX( "findElementByCssSelector", pureCore.elementMethod.cssSelector, Description );439 }440 441 // ************************************************************************************************************************ 442 // AndroidElement [10] = public org.openqa.selenium.WebElement io.appium.java_client.android.AndroidElement.findElementByXPath(java.lang.String)443 // IOSElement [10] = public org.openqa.selenium.WebElement io.appium.java_client.ios.IOSElement.findElementByXPath(java.lang.String)444 // MobileElement [13] = public org.openqa.selenium.WebElement io.appium.java_client.MobileElement.findElementByXPath(java.lang.String)445 public pureElement findElementByXPath( String Description ){446 return this.intFindElementXXX( "findElementByXPath", pureCore.elementMethod.xpath, Description );447 }448 449 // ************************************************************************************************************************ 450 // AndroidElement [11] = public org.openqa.selenium.WebElement io.appium.java_client.android.AndroidElement.findElementById(java.lang.String)451 // IOSElement [11] = public org.openqa.selenium.WebElement io.appium.java_client.ios.IOSElement.findElementById(java.lang.String)452 // MobileElement [21] = public org.openqa.selenium.WebElement io.appium.java_client.MobileElement.findElementById(java.lang.String)453 public pureElement findElementById( String Description ){454 return this.intFindElementXXX( "findElementById", pureCore.elementMethod.id, Description );455 }456 457 // ************************************************************************************************************************ 458 // AndroidElement [14] = public void io.appium.java_client.android.AndroidElement.replaceValue(java.lang.String)459 public void replaceValue( java.lang.String value ) {460 this.refresh();461 this.centerOnScreen(); // Method to put object in center of the screen if partially or not visible462 this.pureElementMethodCall( "replaceValue", (Object)value );463 }464 465 // ************************************************************************************************************************ 466 // AndroidElement [15] = public void io.appium.java_client.MobileElement.setValue(java.lang.String)467 // IOSElement [14] = public void io.appium.java_client.MobileElement.setValue(java.lang.String)468 // MobileElement [2] = public void io.appium.java_client.MobileElement.setValue(java.lang.String)469 public void setValue( java.lang.String value ) {470 this.refresh();471 this.centerOnScreen(); // Method to put object in center of the screen if partially or not visible472 this.pureElementMethodCall( "setValue", (Object)value );473 }474 // ************************************************************************************************************************ 475 // AndroidElement [17] = public java.util.List io.appium.java_client.MobileElement.findElements(java.lang.String,java.lang.String)476 // IOSElement [16] = public java.util.List io.appium.java_client.MobileElement.findElements(java.lang.String,java.lang.String)477 // MobileElement [6] = public java.util.List io.appium.java_client.MobileElement.findElements(java.lang.String,java.lang.String)478 479 // ************************************************************************************************************************ 480 // Internal optimisation for the following findElementsXXX methods481 private pureElements intFindElementsXXX( String MethodName, int elementMethod, String Description ) {482 this.refresh(); // Method to detect, update and centre the object on screen if existing.483 Object feedback = this.pureElementMethodCall( MethodName, (Object)Description );484 List<Object> myObjectList = pureCore.CastObjecttoList( feedback );485 if ( myObjectList != null ) {486 pureElements newPureElements = new pureElements( "-", "-", elementMethod, Description, pureCore.defRefreshMode, this );487 newPureElements.theElements = myObjectList;488 newPureElements.refrehCode = "0xFFFFFFFF";489 return newPureElements;490 }else {491 return null;492 }493 }494 // ************************************************************************************************************************ 495 // AndroidElement [18] = public java.util.List io.appium.java_client.MobileElement.findElementsByLinkText(java.lang.String)496 // IOSElement [17] = public java.util.List io.appium.java_client.MobileElement.findElementsByLinkText(java.lang.String)497 // MobileElement [14] = public java.util.List io.appium.java_client.MobileElement.findElementsByLinkText(java.lang.String)498 public pureElements findElementsByLinkText( java.lang.String Description ){499 return intFindElementsXXX( "findElementsByLinkText", pureCore.elementMethod.linkText, Description );500 }501 // ************************************************************************************************************************ 502 // AndroidElement [19] = public java.util.List io.appium.java_client.MobileElement.findElementsByPartialLinkText(java.lang.String)503 // IOSElement [18] = public java.util.List io.appium.java_client.MobileElement.findElementsByPartialLinkText(java.lang.String)504 // MobileElement [15] = public java.util.List io.appium.java_client.MobileElement.findElementsByPartialLinkText(java.lang.String)505 public pureElements findElementsByPartialLinkText( java.lang.String Description ){506 return intFindElementsXXX( "findElementsByPartialLinkText", pureCore.elementMethod.partialLinkText, Description );507 }508 509 // ************************************************************************************************************************ 510 // AndroidElement [20] = public java.util.List io.appium.java_client.MobileElement.findElementsByTagName(java.lang.String)511 // IOSElement [19] = public java.util.List io.appium.java_client.MobileElement.findElementsByTagName(java.lang.String)512 // MobileElement [16] = public java.util.List io.appium.java_client.MobileElement.findElementsByTagName(java.lang.String)513 public pureElements findElementsByTagName( java.lang.String Description ){514 return intFindElementsXXX( "findElementsByTagName", pureCore.elementMethod.tagNamei, Description );515 }516 517 // ************************************************************************************************************************ 518 // AndroidElement [21] = public java.util.List io.appium.java_client.MobileElement.findElementsByName(java.lang.String)519 // IOSElement [20] = public java.util.List io.appium.java_client.MobileElement.findElementsByName(java.lang.String)520 // MobileElement [17] = public java.util.List io.appium.java_client.MobileElement.findElementsByName(java.lang.String)521 public pureElements findElementsByName( java.lang.String Description ){522 return intFindElementsXXX( "findElementsByName", pureCore.elementMethod.name, Description );523 }524 525 // ************************************************************************************************************************ 526 // AndroidElement [22] = public java.util.List io.appium.java_client.MobileElement.findElementsByClassName(java.lang.String)527 // IOSElement [21] = public java.util.List io.appium.java_client.MobileElement.findElementsByClassName(java.lang.String)528 // MobileElement [18] = public java.util.List io.appium.java_client.MobileElement.findElementsByClassName(java.lang.String)529 public pureElements findElementsByClassName( java.lang.String Description ){530 return intFindElementsXXX( "findElementsByClassName", pureCore.elementMethod.className, Description );531 }532 533 // ************************************************************************************************************************ 534 // AndroidElement [23] = public java.util.List io.appium.java_client.MobileElement.findElementsByCssSelector(java.lang.String)535 // IOSElement [22] = public java.util.List io.appium.java_client.MobileElement.findElementsByCssSelector(java.lang.String)536 // MobileElement [19] = public java.util.List io.appium.java_client.MobileElement.findElementsByCssSelector(java.lang.String)537 public pureElements findElementsByCssSelector( java.lang.String Description ){538 return intFindElementsXXX( "findElementsByCssSelector", pureCore.elementMethod.cssSelector, Description );539 }540 541 // ************************************************************************************************************************ 542 // AndroidElement [24] = public java.util.List io.appium.java_client.MobileElement.findElementsByXPath(java.lang.String)543 // IOSElement [23] = public java.util.List io.appium.java_client.MobileElement.findElementsByXPath(java.lang.String)544 // MobileElement [20] = public java.util.List io.appium.java_client.MobileElement.findElementsByXPath(java.lang.String)545 public pureElements findElementsByXPath( java.lang.String Description ){546 return intFindElementsXXX( "findElementsByXPath", pureCore.elementMethod.xpath, Description );547 }548 549 // ************************************************************************************************************************ 550 // AndroidElement [25] = public java.util.List io.appium.java_client.MobileElement.findElementsById(java.lang.String)551 // IOSElement [24] = public java.util.List io.appium.java_client.MobileElement.findElementsById(java.lang.String)552 // MobileElement [22] = public java.util.List io.appium.java_client.MobileElement.findElementsById(java.lang.String)553 public pureElements findElementsById( java.lang.String Description ){554 return intFindElementsXXX( "findElementsById", pureCore.elementMethod.id, Description );555 }556 557 // ************************************************************************************************************************ 558 // AndroidElement [26] = public java.util.List io.appium.java_client.MobileElement.findElementsByAccessibilityId(java.lang.String)559 // IOSElement [25] = public java.util.List io.appium.java_client.MobileElement.findElementsByAccessibilityId(java.lang.String)560 // MobileElement [26] = public java.util.List io.appium.java_client.MobileElement.findElementsByAccessibilityId(java.lang.String)561 public pureElements findElementsByAccessibilityId( java.lang.String Description ){562 return intFindElementsXXX( "findElementsByAccessibilityId", pureCore.elementMethod.AccessibilityId, Description );563 }564 565 // ************************************************************************************************************************ 566 // AndroidElement [27] = public org.openqa.selenium.Point io.appium.java_client.MobileElement.getCenter()567 // IOSElement [26] = public org.openqa.selenium.Point io.appium.java_client.MobileElement.getCenter()568 // MobileElement [25] = public org.openqa.selenium.Point io.appium.java_client.MobileElement.getCenter()569 public org.openqa.selenium.Point getCenter(){570 this.refresh();571 return (org.openqa.selenium.Point)this.pureElementMethodCall( "getCenter" );572 }573 // ************************************************************************************************************************ 574 // AndroidElement [28] = public boolean org.openqa.selenium.remote.RemoteWebElement.equals(java.lang.Object)575 // IOSElement [27] = public boolean org.openqa.selenium.remote.RemoteWebElement.equals(java.lang.Object)576 // MobileElement [27] = public boolean org.openqa.selenium.remote.RemoteWebElement.equals(java.lang.Object)577 public boolean equalsL( Object equalsto ){578 this.refresh();579 return (boolean)this.pureElementMethodCall( "equals", equalsto );580 }581 582 // ************************************************************************************************************************ 583 // AndroidElement [29] = public java.lang.String org.openqa.selenium.remote.RemoteWebElement.toString()584 // IOSElement [28] = public java.lang.String org.openqa.selenium.remote.RemoteWebElement.toString()585 // MobileElement [28] = public java.lang.String org.openqa.selenium.remote.RemoteWebElement.toString()586 public java.lang.String toStringL(){587 this.refresh();588 return (String)this.pureElementMethodCall( "toString" );589 }590 591 // ************************************************************************************************************************ 592 // AndroidElement [30] = public int org.openqa.selenium.remote.RemoteWebElement.hashCode()593 // IOSElement [29] = public int org.openqa.selenium.remote.RemoteWebElement.hashCode()594 // MobileElement [29] = public int org.openqa.selenium.remote.RemoteWebElement.hashCode()595 public int hashCodeL(){596 this.refresh();597 return (int)this.pureElementMethodCall( "hashCode" );598 }599 600 // ************************************************************************************************************************ 601 // AndroidElement [33] = public java.lang.String org.openqa.selenium.remote.RemoteWebElement.getId()602 // IOSElement [32] = public java.lang.String org.openqa.selenium.remote.RemoteWebElement.getId()603 // MobileElement [32] = public java.lang.String org.openqa.selenium.remote.RemoteWebElement.getId()604 public java.lang.String getId(){605 this.refresh();606 return (java.lang.String)this.pureElementMethodCall( "getId" );607 }608 // ************************************************************************************************************************ 609 // AndroidElement [35] = public void org.openqa.selenium.remote.RemoteWebElement.setParent(org.openqa.selenium.remote.RemoteWebDriver)610 // IOSElement [34] = public void org.openqa.selenium.remote.RemoteWebElement.setParent(org.openqa.selenium.remote.RemoteWebDriver)611 // MobileElement [34] = public void org.openqa.selenium.remote.RemoteWebElement.setParent(org.openqa.selenium.remote.RemoteWebDriver)612 public void setParent( org.openqa.selenium.remote.RemoteWebDriver remoteWebDriver ){613 this.refresh();614 this.pureElementMethodCall( "setParent", remoteWebDriver );615 }616 // ************************************************************************************************************************ 617 // AndroidElement [36] = public void org.openqa.selenium.remote.RemoteWebElement.setFileDetector(org.openqa.selenium.remote.FileDetector)618 // IOSElement [35] = public void org.openqa.selenium.remote.RemoteWebElement.setFileDetector(org.openqa.selenium.remote.FileDetector)619 // MobileElement [35] = public void org.openqa.selenium.remote.RemoteWebElement.setFileDetector(org.openqa.selenium.remote.FileDetector)620 public void setFileDetector( org.openqa.selenium.remote.FileDetector fileSelector ) {621 this.refresh();622 this.pureElementMethodCall( "setFileDetector", fileSelector );623 }624 625 // ************************************************************************************************************************ 626 // AndroidElement [47] = public org.openqa.selenium.WebDriver org.openqa.selenium.remote.RemoteWebElement.getWrappedDriver()627 // IOSElement [48] = public org.openqa.selenium.WebDriver org.openqa.selenium.remote.RemoteWebElement.getWrappedDriver()628 // MobileElement [46] = public org.openqa.selenium.WebDriver org.openqa.selenium.remote.RemoteWebElement.getWrappedDriver()629/* public pureDrivers getWrappedDriver(){630 this.refresh();631 Object SourceObject = this.pureElementMethodCall( "getWrappedDriver" );632 if ( SourceObject != null ) {633 pureDrivers newDriver = new pureDrivers();634 newDriver.DriverName = "WrappedDriver";635 newDriver.subDriverName = "";636 newDriver.mainDriver = SourceObject;637 return newDriver;638 }else {639 return null;640 }641 } */642 643 // ************************************************************************************************************************ 644 // AndroidElement [48] = public org.openqa.selenium.interactions.internal.Coordinates org.openqa.selenium.remote.RemoteWebElement.getCoordinates()645 // IOSElement [49] = public org.openqa.selenium.interactions.internal.Coordinates org.openqa.selenium.remote.RemoteWebElement.getCoordinates()646 // MobileElement [47] = public org.openqa.selenium.interactions.internal.Coordinates org.openqa.selenium.remote.RemoteWebElement.getCoordinates()647 public org.openqa.selenium.interactions.internal.Coordinates getCoordinates(){648 this.refresh();649 return (org.openqa.selenium.interactions.internal.Coordinates)this.pureElementMethodCall( "getCoordinates" );650 }651 652 // ************************************************************************************************************************ 653 // AndroidElement [49] = public java.util.Map org.openqa.selenium.remote.RemoteWebElement.toJson()654 // IOSElement [46] = public java.util.Map org.openqa.selenium.remote.RemoteWebElement.toJson()655 // MobileElement [48] = public java.util.Map org.openqa.selenium.remote.RemoteWebElement.toJson()656 public java.util.Map<?,?> toJson(){657 this.refresh();658 return (java.util.Map<?,?>)this.pureElementMethodCall( "toJson" );659 }660 661 // ************************************************************************************************************************ 662 // AndroidElement [50] = public void org.openqa.selenium.remote.RemoteWebElement.setId(java.lang.String)663 // IOSElement [47] = public void org.openqa.selenium.remote.RemoteWebElement.setId(java.lang.String)664 // MobileElement [49] = public void org.openqa.selenium.remote.RemoteWebElement.setId(java.lang.String)665 public void setId( java.lang.String Value ) {666 this.refresh();667 this.pureElementMethodCall( "setId", Value );668 }669 670 // ************************************************************************************************************************ 671 // AndroidElement [51] = public final void java.lang.Object.wait() throws java.lang.InterruptedException672 // IOSElement [50] = public final void java.lang.Object.wait() throws java.lang.InterruptedException673 // MobileElement [50] = public final void java.lang.Object.wait() throws java.lang.InterruptedException674 public void waitL(){675 this.refresh();676 this.pureElementMethodCall( "wait" );677 }678 679 // ************************************************************************************************************************ 680 // AndroidElement [52] = public final void java.lang.Object.wait(long,int) throws java.lang.InterruptedException681 // IOSElement [51] = public final void java.lang.Object.wait(long,int) throws java.lang.InterruptedException682 // MobileElement [51] = public final void java.lang.Object.wait(long,int) throws java.lang.InterruptedException683 public void waitL( long waitdelay, int waitdelayms ){684 this.refresh();685 this.pureElementMethodCall( "wait", waitdelay, waitdelayms );686 }687 688 // ************************************************************************************************************************ 689 // AndroidElement [53] = public final native void java.lang.Object.wait(long) throws java.lang.InterruptedException690 // IOSElement [52] = public final native void java.lang.Object.wait(long) throws java.lang.InterruptedException691 // MobileElement [52] = public final native void java.lang.Object.wait(long) throws java.lang.InterruptedException692 public void waitL( long waitdelay ){693 this.refresh();694 this.pureElementMethodCall( "wait", waitdelay );695 }696 697 // ************************************************************************************************************************ 698 // AndroidElement [54] = public final native java.lang.Class java.lang.Object.getClass()699 // IOSElement [53] = public final native java.lang.Class java.lang.Object.getClass()700 // MobileElement [53] = public final native java.lang.Class java.lang.Object.getClass()701 public java.lang.Class<?> getClassL(){702 this.refresh();703 return (java.lang.Class<?>)this.pureElementMethodCall( "getClass" );704 }705 706 // ************************************************************************************************************************ 707 // AndroidElement [55] = public final native void java.lang.Object.notify()708 // IOSElement [54] = public final native void java.lang.Object.notify()709 // MobileElement [54] = public final native void java.lang.Object.notify()710 public void notifyL(){711 this.refresh();712 this.pureElementMethodCall( "notify" );713 }714 715 // ************************************************************************************************************************ 716 // AndroidElement [56] = public final native void java.lang.Object.notifyAll()717 // IOSElement [55] = public final native void java.lang.Object.notifyAll()718 // MobileElement [55] = public final native void java.lang.Object.notifyAll()719 public void notifyAllL(){720 this.refresh();721 this.pureElementMethodCall( "notifyAll" );722 }723 724 // ************************************************************************************************************************ 725 // AndroidElement [57] = public default org.openqa.selenium.WebElement io.appium.java_client.FindsByAccessibilityId.findElementByAccessibilityId(java.lang.String)726 // IOSElement [56] = public default org.openqa.selenium.WebElement io.appium.java_client.FindsByAccessibilityId.findElementByAccessibilityId(java.lang.String)727 // MobileElement [56] = public default org.openqa.selenium.WebElement io.appium.java_client.FindsByAccessibilityId.findElementByAccessibilityId(java.lang.String)728 public pureElement findElementByAccessibilityId( String Description ){729 return this.intFindElementXXX( "findElementByAccessibilityId", pureCore.elementMethod.AccessibilityId, Description );730 }731 732 // ************************************************************************************************************************ 733 // AndroidElement [58] = public default org.openqa.selenium.WebElement io.appium.java_client.FindsByAndroidUIAutomator.findElementByAndroidUIAutomator(java.lang.String)734 public pureElement findElementByAndroidUIAutomator( String Description ){735 return this.intFindElementXXX( "findElementByAndroidUIAutomator", pureCore.elementMethod.AndroidUIAutomator, Description );736 }737 // ************************************************************************************************************************ 738 // AndroidElement [59] = public default java.util.List io.appium.java_client.FindsByAndroidUIAutomator.findElementsByAndroidUIAutomator(java.lang.String)739 public pureElements findElementsByAndroidUIAutomator( String Description ) {740 return this.intFindElementsXXX( "findElementsByAndroidUIAutomator", pureCore.elementMethod.AndroidUIAutomator, Description );741 }742 // ************************************************************************************************************************ 743 // IOSElement [57] = public default org.openqa.selenium.WebElement io.appium.java_client.FindsByIosUIAutomation.findElementByIosUIAutomation(java.lang.String)744 public pureElement findElementByIosUIAutomation( String Description ){745 return this.intFindElementXXX( "findElementByIosUIAutomation", pureCore.elementMethod.IosUIAutomation, Description );746 }747 // ************************************************************************************************************************ 748 // IOSElement [58] = public default java.util.List io.appium.java_client.FindsByIosUIAutomation.findElementsByIosUIAutomation(java.lang.String)749 public pureElements findElementsByIosUIAutomation( String Description ) {750 return this.intFindElementsXXX( "findElementsByIosUIAutomation", pureCore.elementMethod.IosUIAutomation, Description );751 }752 // ************************************************************************************************************************ 753 // IOSElement [59] = public default org.openqa.selenium.WebElement io.appium.java_client.FindsByIosNSPredicate.findElementByIosNsPredicate(java.lang.String)754 public pureElement findElementByIosNsPredicate( String Description ){755 return this.intFindElementXXX( "findElementByIosNsPredicate", pureCore.elementMethod.IosNsPredicate, Description );756 }757 // ************************************************************************************************************************ 758 // IOSElement [60] = public default java.util.List io.appium.java_client.FindsByIosNSPredicate.findElementsByIosNsPredicate(java.lang.String)759 public pureElements findElementsByIosNsPredicate( String Description ) {760 return this.intFindElementsXXX( "findElementsByIosNsPredicate", pureCore.elementMethod.IosNsPredicate, Description );761 }762 // ************************************************************************************************************************ 763 // IOSElement [61] = public default org.openqa.selenium.WebElement io.appium.java_client.FindsByIosClassChain.findElementByIosClassChain(java.lang.String)764 public pureElement findElementByIosClassChain( String Description ){765 return this.intFindElementXXX( "findElementByIosClassChain", pureCore.elementMethod.IosClassChain, Description );766 }767 // ************************************************************************************************************************ 768 // IOSElement [62] = public default java.util.List io.appium.java_client.FindsByIosClassChain.findElementsByIosClassChain(java.lang.String)769 public pureElements findElementsByIosClassChain( String Description ) {770 return this.intFindElementsXXX( "findElementsByIosClassChain", pureCore.elementMethod.IosClassChain, Description );771 }772 // ************************************************************************************************************************ 773 private void refresh() {774 // Si l'Element n'a pas encore ete cherche, ou que son rafraichissement doit etre realise.775 if ( this.theElement == null || this.refreshMethod == 1 ) { // || this.refrehCode != pureCore.getLastLogCat() ) {776 pureDriverDetails myDriver = null;777 if ( this.driverLink == -1 ) {778 myDriver = pureDrivers.getCurrentDriverDetails();779 // this.driverToUse = myDriver;780 }else {781 myDriver = this.driverToUse;782 }783 this.theElement = this.detection();784 // Tout d'abord on réalise une attente pour trouver l'élément.785 /*try {786 this.theElement = (Object)(new WebDriverWait( (WebDriver)pureCore.getCurrentDriver(), pureCore.getMaxWaitDelay() )787 .until( ExpectedConditions.presenceOfElementLocated( By.xpath( pureCore.MethodToLocator( this.eMethod, this.ePath ) ) ) ) );788 }catch( Exception e ) {789 pureErrorHandler.castError( pureErrorHandler.exceptions.getType( e ), "pureElement.refresh()", this.eName, pureCore.MethodToLocator( this.eMethod, this.ePath ) );790 } */791 if ( this.parent == null ) {792 this.theElement = (Object)pureDrivers.findElementWE( pureCore.MethodToLocator( this.eMethod, this.ePath ), myDriver );793 }else {794 this.theElement = (Object)this.parent.findElement( pureCore.MethodToLocator( this.eMethod, this.ePath ) );795 }796 // this.centerOnScreen();797 }798 }799 public Object myObject = null;800 private Object detection() {801 pureDriverDetails myDriver = null;802 if ( this.driverLink == -1 ) {803 myDriver = pureDrivers.getCurrentDriverDetails();804 }else {805 myDriver = this.driverToUse;806 }807 try {808 WebDriverWait objWait = new WebDriverWait( (WebDriver)myDriver.mainDriver, 20, 500 );809 objWait.until( new ExpectedCondition<Boolean>() {810 private pureElement myElement;811 private pureDriverDetails myDriver;812 private ExpectedCondition<Boolean> init( pureElement myElement, pureDriverDetails myDriver ){813 this.myElement = myElement;814 this.myDriver = myDriver;815 return this;816 }817 public Boolean apply(WebDriver wDriver) {818 if( this.myElement.parent == null ) {819 this.myElement.theElement = (Object)pureDrivers.findElementWE( pureCore.MethodToLocator( this.myElement.eMethod, this.myElement.ePath ), this.myDriver );820 }else {821 this.myElement.theElement = (Object)this.myElement.parent.findElement( pureCore.MethodToLocator( this.myElement.eMethod, this.myElement.ePath ) );822 }823 return ( this.myElement.theElement != null );824 }825 }.init( this, myDriver ) );826 827 }catch( Exception e ) {828 pureErrorHandler.castError( pureErrorHandler.exceptions.getType( e ), "pureElement.refresh()", this.eName, pureCore.MethodToLocator( this.eMethod, this.ePath ).toString() );829 }830 return myObject;831 }832 // ************************************************************************************************************************ 833private void centerOnScreen() {834 pureDriverDetails myDriver = pureDrivers.getCurrentDriverDetails();835 // Positionner l'objet au milieu de l'ecran si possible836 if ( this.theElement !=null ) {837 // On recupere d'abord les coordonnees et dimensions de l'objet838 Point pePosition = this.getLocation();839 Dimension peDimension = this.getSize();840 // On recupere ensuite les coordonnees et dimensions de l'ecran visible841 Rectangle cdRectangle = pureDrivers.GetDisplayArea();842 // Si l'objet est plus haut que l'ecran visible (et partiellement ou totalement hors ecran) :843 if ( pePosition.getY() < cdRectangle.getY() ) {844 int yShift = ( cdRectangle.getY() - pePosition.getY() ) + ( ( cdRectangle.getHeight() / 2 ) - ( peDimension.getHeight() / 2 ) );845 // Scroller vers le haut de la page, d'une valeur de yShift pixels846 JavascriptExecutor jse = (JavascriptExecutor)myDriver.mainDriver;847 jse.executeScript("window.scrollTo( " + ( cdRectangle.getY() - yShift ) + "," + "0" + ")" );848 }849 // Si l'objet est plus bas que l'ecran visible (et partiellement ou totalement hors ecran) :850 if ( ( pePosition.getY() + peDimension.getHeight() ) > ( cdRectangle.getY() + cdRectangle.getHeight() ) ){851 int yShift = ( ( pePosition.getY() + peDimension.getHeight() ) - ( cdRectangle.getY() + cdRectangle.getHeight() ) ) + 852 ( ( cdRectangle.getHeight() / 2 ) - ( peDimension.getHeight() / 2 ) );853 // Scroller vers le bas de la page, d'une valeur de yShift pixels854 JavascriptExecutor jse = (JavascriptExecutor)myDriver.mainDriver;855 jse.executeScript("window.scrollTo( " + ( cdRectangle.getY() + yShift ) + "," + "0" + ")" );856 }857 }858 859}860 861 // ************************************************************************************************************************ 862 private Object pureElementMethodCall( String MethodToCall, Object Param1, Object Param2, Object Param3 ) {863 pureDriverDetails myDriver = null;864 if ( this.driverToUse != null ) {865 myDriver = this.driverToUse;866 }else {867 myDriver = pureDrivers.getCurrentDriverDetails();868 }869 int modSize = ( ( Param1 != null ) ? 1: 0 ) + ( ( Param2 != null ) ? 1: 0 ) + ( ( Param2 != null ) ? 1: 0 );...

Full Screen

Full Screen

Source:CustomLocatorHandler.java Github

copy

Full Screen

...74 CustomLocatorHandler(Node node, Secret registrationSecret, Set<CustomLocator> extraLocators) {75 Require.nonNull("Node", node);76 Require.nonNull("Registration secret", registrationSecret);77 Require.nonNull("Extra locators", extraLocators);78 HttpHandler nodeHandler = node::executeWebDriverCommand;79 this.toNode = nodeHandler.with(new AddSeleniumUserAgent())80 .with(new AddWebDriverSpecHeaders())81 .with(new AddSecretFilter(registrationSecret));82 this.extraLocators = extraLocators.stream()83 .collect(Collectors.toMap(CustomLocator::getLocatorName, locator -> locator::createBy));84 }85 @Override86 public boolean matches(HttpRequest req) {87 if (req.getMethod() != HttpMethod.POST) {88 return false;89 }90 return FIND_ELEMENT.match(req.getUri()) != null ||91 FIND_ELEMENTS.match(req.getUri()) != null ||92 FIND_CHILD_ELEMENT.match(req.getUri()) != null ||93 FIND_CHILD_ELEMENTS.match(req.getUri()) != null;94 }95 @Override96 public HttpResponse execute(HttpRequest req) throws UncheckedIOException {97 String originalContents = Contents.string(req);98 // There has to be a nicer way of doing this.99 Map<String, Object> contents = JSON.toType(originalContents, MAP_TYPE);100 Object using = contents.get("using");101 if (!(using instanceof String)) {102 return new HttpResponse()103 .setStatus(HTTP_BAD_REQUEST)104 .setContent(Contents.asJson(ImmutableMap.of(105 "value", ImmutableMap.of(106 "error", "invalid argument",107 "message", "Unable to determine element locating strategy",108 "stacktrace", ""))));109 }110 if (W3C_STRATEGIES.contains(using)) {111 // TODO: recreate the original request112 return toNode.execute(req);113 }114 Object value = contents.get("value");115 if (value == null) {116 return new HttpResponse()117 .setStatus(HTTP_BAD_REQUEST)118 .setContent(Contents.asJson(ImmutableMap.of(119 "value", ImmutableMap.of(120 "error", "invalid argument",121 "message", "Unable to determine element locator arguments",122 "stacktrace", ""))));123 }124 Function<Object, By> customLocator = extraLocators.get(using);125 if (customLocator == null) {126 return new HttpResponse()127 .setStatus(HTTP_BAD_REQUEST)128 .setContent(Contents.asJson(ImmutableMap.of(129 "value", ImmutableMap.of(130 "error", "invalid argument",131 "message", "Unable to determine element locating strategy for " + using,132 "stacktrace", ""))));133 }134 CommandExecutor executor = new NodeWrappingExecutor(toNode);135 RemoteWebDriver driver = new CustomWebDriver(136 executor,137 HttpSessionId.getSessionId(req.getUri())138 .orElseThrow(() -> new IllegalArgumentException("Cannot locate session ID from " + req.getUri())));139 SearchContext context = null;140 RemoteWebElement element;141 boolean findMultiple = false;142 UrlTemplate.Match match = FIND_ELEMENT.match(req.getUri());143 if (match != null) {144 element = new RemoteWebElement();145 element.setParent(driver);146 element.setId(match.getParameters().get("elementId"));147 context = driver;148 }149 match = FIND_ELEMENTS.match(req.getUri());150 if (match != null) {151 element = new RemoteWebElement();152 element.setParent(driver);153 element.setId(match.getParameters().get("elementId"));154 context = driver;155 findMultiple = true;156 }157 match = FIND_CHILD_ELEMENT.match(req.getUri());158 if (match != null) {159 element = new RemoteWebElement();160 element.setParent(driver);161 element.setId(match.getParameters().get("elementId"));162 context = element;163 }164 match = FIND_CHILD_ELEMENTS.match(req.getUri());165 if (match != null) {166 element = new RemoteWebElement();167 element.setParent(driver);168 element.setId(match.getParameters().get("elementId"));169 context = element;170 findMultiple = true;171 }172 if (context == null) {173 throw new IllegalStateException("Unable to determine locator context: " + req);174 }175 Object toReturn;176 By by = customLocator.apply(value);177 if (findMultiple) {178 toReturn = context.findElements(by);179 } else {180 toReturn = context.findElement(by);181 }182 return new HttpResponse()183 .setContent(Contents.asJson(ImmutableMap.of("value", toReturn)));184 }185 private static class NodeWrappingExecutor implements CommandExecutor {186 private final HttpHandler toNode;187 private final CommandCodec<HttpRequest> commandCodec;188 private final ResponseCodec<HttpResponse> responseCodec;189 public NodeWrappingExecutor(HttpHandler toNode) {190 this.toNode = Require.nonNull("Node", toNode);191 commandCodec = new W3CHttpCommandCodec();192 responseCodec = new W3CHttpResponseCodec();193 }194 @Override195 public Response execute(Command command) throws IOException {196 if (DriverCommand.NEW_SESSION.equals(command.getName())) {197 Response response = new Response();198 response.setState("session not created");199 return response;200 }201 if (command.getSessionId() == null) {202 Response response = new Response();203 response.setState("invalid session id");204 return response;205 }206 HttpRequest request = commandCodec.encode(command);207 HttpResponse response = toNode.execute(request);208 Response decoded = responseCodec.decode(response);209 decoded.setSessionId(command.getSessionId().toString());210 return decoded;211 }212 }213 private static class CustomWebDriver extends RemoteWebDriver {214 public CustomWebDriver(CommandExecutor executor, String sessionId) {215 super(executor, new ImmutableCapabilities());216 setSessionId(sessionId);217 }218 @Override219 protected void startSession(Capabilities capabilities) {220 // no-op221 }...

Full Screen

Full Screen

Source:CalendarDynamicWebtableTwo.java Github

copy

Full Screen

...78 at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)79 at java.lang.reflect.Constructor.newInstance(Constructor.java:526)80 at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)81 at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)82 at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678)83 at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:327)84 at org.openqa.selenium.remote.RemoteWebElement.findElements(RemoteWebElement.java:214)85 at org.openqa.selenium.remote.RemoteWebElement.findElementsByTagName(RemoteWebElement.java:320)86 at org.openqa.selenium.By$ByTagName.findElements(By.java:327)87 at org.openqa.selenium.remote.RemoteWebElement.findElements(RemoteWebElement.java:190)88 at Package.WebTable.CalendarDynamicWebtableTwo.main(CalendarDynamicWebtableTwo.java:61)89Caused by: org.openqa.selenium.StaleElementReferenceException: Element is no longer attached to the DOM90For documentation on this error, please visit: http://seleniumhq.org/exceptions/stale_element_reference.html91Build info: version: '2.50.1', revision: 'd7fc91b', time: '2016-01-29 19:08:26'92System info: host: 'VivekanandYG', ip: '192.168.1.2', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_60'93Driver info: driver.version: unknown94 at <anonymous class>.fxdriver.cache.getElementAt(resource://fxdriver/modules/web-element-cache.js:9406)95 at <anonymous class>.Utils.getElementAt(file:///C:/Users/anand/AppData/Local/Temp/anonymous8141215110523029785webdriver-profile/extensions/fxdriver@googlecode.com/components/driver-component.js:8992)96 at <anonymous class>.FirefoxDriver.prototype.findElementsInternal_(file:///C:/Users/anand/AppData/Local/Temp/anonymous8141215110523029785webdriver-profile/extensions/fxdriver@googlecode.com/components/driver-component.js:10737)97 at <anonymous class>.FirefoxDriver.prototype.findChildElements(file:///C:/Users/anand/AppData/Local/Temp/anonymous8141215110523029785webdriver-profile/extensions/fxdriver@googlecode.com/components/driver-component.js:10758)98 at <anonymous class>.DelayedCommand.prototype.executeInternal_/h(file:///C:/Users/anand/AppData/Local/Temp/anonymous8141215110523029785webdriver-profile/extensions/fxdriver@googlecode.com/components/command-processor.js:12595)99 at <anonymous class>.DelayedCommand.prototype.executeInternal_(file:///C:/Users/anand/AppData/Local/Temp/anonymous8141215110523029785webdriver-profile/extensions/fxdriver@googlecode.com/components/command-processor.js:12600)100 at <anonymous class>.DelayedCommand.prototype.execute/<(file:///C:/Users/anand/AppData/Local/Temp/anonymous8141215110523029785webdriver-profile/extensions/fxdriver@googlecode.com/components/command-processor.js:12542)101*/...

Full Screen

Full Screen

Source:TSRScroller.java Github

copy

Full Screen

...47 * at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)48 * at java.lang.reflect.Constructor.newInstance(Constructor.java:526)49 * at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:193)50 * at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)51 * at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:573)52 * at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:268)53 * at org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:79)54 * at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)55 * at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)56 * at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)57 * at java.lang.reflect.Method.invoke(Method.java:606)58 * at org.openqa.selenium.support.events.EventFiringWebDriver$EventFiringWebElement$1.invoke(EventFiringWebDriver.java:331)59 * at com.sun.proxy.$Proxy33.click(Unknown Source)60 * at org.openqa.selenium.support.events.EventFiringWebDriver$EventFiringWebElement.click(EventFiringWebDriver.java:344)61 * at org.jenkinsci.test.acceptance.po.CapybaraPortingLayer.clickButton(CapybaraPortingLayer.java:66)62 * at org.jenkinsci.test.acceptance.po.JenkinsConfig.addTool(JenkinsConfig.java:35)63 * at org.jenkinsci.test.acceptance.plugins.ant.AntInstallation.install(AntInstallation.java:37)64 * at plugins.AntPluginTest.autoInstallAnt(AntPluginTest.java:76)65 * </pre>66 *67 * <p>68 * This work around simply tries to scroll the element into a view before we interact with this.69 * Originally developed in Ruby version of selenium-tests in <tt>lib/jenkins/capybara.rb</tt>.70 *71 * @author ogondza72 * @author Kohsuke Kawaguchi73 */74public class TSRScroller extends AbstractWebDriverEventListener {75 private final String scrollJs;76 public Scroller() throws IOException {77 scrollJs = IOUtils.toString(Scroller.class.getResourceAsStream("scroller.js"));78 }79 @Override80 public void beforeClickOn(WebElement element, WebDriver driver) {81 scrollIntoView(element, driver);82 }83 @Override84 public void beforeChangeValueOf(WebElement element, WebDriver driver) {85 scrollIntoView(element, driver);86 }87 private void scrollIntoView(WebElement e, WebDriver driver) {88 ((JavascriptExecutor)driver).executeScript(scrollJs,e);89 }90}...

Full Screen

Full Screen

Source:Scroller.java Github

copy

Full Screen

...33 * at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)34 * at java.lang.reflect.Constructor.newInstance(Constructor.java:526)35 * at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:193)36 * at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)37 * at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:573)38 * at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:268)39 * at org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:79)40 * at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)41 * at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)42 * at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)43 * at java.lang.reflect.Method.invoke(Method.java:606)44 * at org.openqa.selenium.support.events.EventFiringWebDriver$EventFiringWebElement$1.invoke(EventFiringWebDriver.java:331)45 * at com.sun.proxy.$Proxy33.click(Unknown Source)46 * at org.openqa.selenium.support.events.EventFiringWebDriver$EventFiringWebElement.click(EventFiringWebDriver.java:344)47 * at org.jenkinsci.test.acceptance.po.CapybaraPortingLayer.clickButton(CapybaraPortingLayer.java:66)48 * at org.jenkinsci.test.acceptance.po.JenkinsConfig.addTool(JenkinsConfig.java:35)49 * at org.jenkinsci.test.acceptance.plugins.ant.AntInstallation.install(AntInstallation.java:37)50 * at plugins.AntPluginTest.autoInstallAnt(AntPluginTest.java:76)51 * </pre>52 *53 * <p>54 * This work around simply tries to scroll the element into a view before we interact with this.55 * Originally developed in Ruby version of selenium-tests in <tt>lib/jenkins/capybara.rb</tt>.56 *57 * @author ogondza58 * @author Kohsuke Kawaguchi59 */60public class Scroller extends AbstractWebDriverEventListener {61 private final String scrollJs;62 public Scroller() throws IOException {63 scrollJs = IOUtils.toString(Scroller.class.getResourceAsStream("scroller.js"));64 }65 @Override66 public void beforeClickOn(WebElement element, WebDriver driver) {67 scrollIntoView(element, driver);68 }69 @Override70 public void beforeChangeValueOf(WebElement element, WebDriver driver) {71 scrollIntoView(element, driver);72 }73 private void scrollIntoView(WebElement e, WebDriver driver) {74 ((JavascriptExecutor)driver).executeScript(scrollJs,e);75 }76}...

Full Screen

Full Screen

Source:ChromeDriver.java Github

copy

Full Screen

...74 }75 76 /**77 * Executes a passed command using the current ChromeCommandExecutor78 * @param driverCommand command to execute79 * @param parameters parameters of command being executed80 * @return response to the command (a Response wrapping a null value if none) 81 */82 @Override83 protected Response execute(String driverCommand, Map<String, ?> parameters) {84 try {85 return super.execute(driverCommand, parameters);86 } catch (Exception e) {87 if (e instanceof IllegalArgumentException ||88 e instanceof FatalChromeException) {89 //These exceptions may leave the extension hung, or in an90 //inconsistent state, so we restart Chrome91 stopClient();92 startClient();93 }94 if (e instanceof RuntimeException) {95 throw (RuntimeException)e;96 } else {97 throw new WebDriverException(e);98 }99 }100 }101102 @Override103 public boolean isJavascriptEnabled() {104 return true;105 }106107 @Override108 protected RemoteWebElement newRemoteWebElement() {109 RemoteWebElement element = new ChromeWebElement(this);110 return element;111 }112113 public <X> X getScreenshotAs(OutputType<X> target) {114 return target.convertFromBase64Png(execute(SCREENSHOT, ImmutableMap.<String, Object>of())115 .getValue().toString());116 }117} ...

Full Screen

Full Screen

Source:ChromeDriverClient.java Github

copy

Full Screen

...40 41 public boolean tapById(String id) {42 try{43 Map<String, ?> params = ImmutableMap.of("element", ((RemoteWebElement)driver.findElement(By.id(id))).getId());44 ((RobotRemoteWebDriver)this.driver).execute(DriverCommand.TOUCH_SINGLE_TAP, params);45 }catch(Exception ex) {46 return false;47 }48 return true;49 }50 51 public boolean tapByXPath(String xpath) {52 try {53 Map<String, ?> params = ImmutableMap.of("element", ((RemoteWebElement)driver.findElement(By.xpath(xpath))).getId());54 ((RobotRemoteWebDriver)this.driver).execute(DriverCommand.TOUCH_SINGLE_TAP, params);55 }catch(Exception ex) {56 return false;57 }58 return true;59 }60 61 public boolean tap(By by) {62 try {63 Map<String, ?> params = ImmutableMap.of("element", ((RemoteWebElement)driver.findElement(by)).getId());64 ((RobotRemoteWebDriver)this.driver).execute(DriverCommand.TOUCH_SINGLE_TAP, params);65 }catch(Exception ex) {66 return false;67 }68 return true;69 }70 71 public void quitDriver() {72 if(driver != null)73 driver.quit();74 }75 76 public WebDriver getDriver() {77 return this.driver;78 }...

Full Screen

Full Screen

Source:AdaptiveWebElement.java Github

copy

Full Screen

...42 } catch (Exception ex) {43 // TODO ios-driver: NullPointerException at RemoteWebElement$1.inViewPort(RemoteWebElement.java:362)44 // Ignore Exception and try a different approach45 }46 ((JavascriptExecutor) getWrappedDriver()).executeScript("return arguments[0].scrollIntoView(true);", this);47 return this;48 }49 @Override50 public void click() {51 scrollIntoView();52 super.click();53 }54 @Override55 public void sendKeys(CharSequence... keysToSend) {56 scrollIntoView();57 super.sendKeys(keysToSend);58 }59}...

Full Screen

Full Screen

execute

Using AI Code Generation

copy

Full Screen

1import org.openqa.selenium.By;2import org.openqa.selenium.WebDriver;3import org.openqa.selenium.WebElement;4import org.openqa.selenium.chrome.ChromeDriver;5import org.openqa.selenium.chrome.ChromeOptions;6import org.openqa.selenium.remote.RemoteWebElement;7public class ExecuteMethod {8 public static void main(String[] args) {9 ChromeOptions options = new ChromeOptions();10 options.addArguments("--start-maximized");11 WebDriver driver = new ChromeDriver(options);12 WebElement searchBox = driver.findElement(By.name("q"));13 RemoteWebElement remoteWebElement = (RemoteWebElement) searchBox;14 remoteWebElement.executeScript("arguments[0].value = 'selenium';", searchBox);15 }16}

Full Screen

Full Screen

execute

Using AI Code Generation

copy

Full Screen

1WebElement element = driver.findElement(By.id("someid"));2((JavascriptExecutor) driver).executeScript("arguments[0].click();", element);3((JavascriptExecutor) driver).executeAsyncScript("arguments[0].click();", element);4((JavascriptExecutor) driver).executeScript("document.getElementById('someid').click();");5((JavascriptExecutor) driver).executeAsyncScript("document.getElementById('someid').click();");6((JavascriptExecutor) driver).executeScript("document.getElementById('someid').click();");7((JavascriptExecutor) driver).executeAsyncScript("document.getElementById('someid').click();");8((JavascriptExecutor) driver).executeScript("document.getElementById('someid').click();");9((JavascriptExecutor) driver).executeAsyncScript("document.getElementById('someid').click();");

Full Screen

Full Screen

execute

Using AI Code Generation

copy

Full Screen

1 .executeScript("window.scrollTo(0, document.body.scrollHeight)");2((JavascriptExecutor) driver).executeScript("window.scrollTo(0, document.body.scrollHeight)");3((JavascriptExecutor) driver).executeScript("window.scrollTo(0, document.body.scrollHeight)");4((JavascriptExecutor) driver).executeScript("window.scrollTo(0, document.body.scrollHeight)");5((JavascriptExecutor) driver).executeScript("window.scrollTo(0, document.body.scrollHeight)");6((JavascriptExecutor) driver).executeScript("window.scrollTo(0, document.body.scrollHeight)");7((JavascriptExecutor) driver).executeScript("window.scrollTo(0, document.body.scrollHeight)");8((JavascriptExecutor) driver).executeScript("window.scrollTo(0, document.body.scrollHeight)");9((JavascriptExecutor) driver).executeScript("window.scrollTo(0, document.body.scrollHeight)");10((JavascriptExecutor) driver).executeScript("window.scrollTo(0, document.body.scrollHeight)");

Full Screen

Full Screen

Selenium 4 Tutorial:

LambdaTest’s Selenium 4 tutorial is covering every aspects of Selenium 4 testing with examples and best practices. Here you will learn basics, such as how to upgrade from Selenium 3 to Selenium 4, to some advanced concepts, such as Relative locators and Selenium Grid 4 for Distributed testing. Also will learn new features of Selenium 4, such as capturing screenshots of specific elements, opening a new tab or window on the browser, and new protocol adoptions.

Chapters:

  1. Upgrading From Selenium 3 To Selenium 4?: In this chapter, learn in detail how to update Selenium 3 to Selenium 4 for Java binding. Also, learn how to upgrade while using different build tools such as Maven or Gradle and get comprehensive guidance for upgrading Selenium.

  2. What’s New In Selenium 4 & What’s Being Deprecated? : Get all information about new implementations in Selenium 4, such as W3S protocol adaption, Optimized Selenium Grid, and Enhanced Selenium IDE. Also, learn what is deprecated for Selenium 4, such as DesiredCapabilites and FindsBy methods, etc.

  3. Selenium 4 With Python: Selenium supports all major languages, such as Python, C#, Ruby, and JavaScript. In this chapter, learn how to install Selenium 4 for Python and the features of Python in Selenium 4, such as Relative locators, Browser manipulation, and Chrom DevTool protocol.

  4. Selenium 4 Is Now W3C Compliant: JSON Wireframe protocol is retiring from Selenium 4, and they are adopting W3C protocol to learn in detail about the advantages and impact of these changes.

  5. How To Use Selenium 4 Relative Locator? : Selenium 4 came with new features such as Relative Locators that allow constructing locators with reference and easily located constructors nearby. Get to know its different use cases with examples.

  6. Selenium Grid 4 Tutorial For Distributed Testing: Selenium Grid 4 allows you to perform tests over different browsers, OS, and device combinations. It also enables parallel execution browser testing, reads up on various features of Selenium Grid 4 and how to download it, and runs a test on Selenium Grid 4 with best practices.

  7. Selenium Video Tutorials: Binge on video tutorials on Selenium by industry experts to get step-by-step direction from automating basic to complex test scenarios with Selenium.

Selenium 101 certifications:

LambdaTest also provides certification for Selenium testing to accelerate your career in Selenium automation testing.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful