@@ -132,7 +132,7 @@ public Point Location() {
132132 /// <summary>
133133 /// Gets the location of an element relative to the origin of the view port.
134134 /// </summary>
135- public Point LocationInViewport ( ) {
135+ public Point LocationInView ( ) {
136136 var dict = ( Dictionary ) Send ( RequestMethod . GET , "/location_in_view" ) ;
137137 return new Point ( dict ) ;
138138 }
@@ -164,6 +164,20 @@ public bool IsDisplayed {
164164 }
165165 }
166166
167+ /// <summary>
168+ /// Whether the element is present
169+ /// </summary>
170+ public bool IsPresent {
171+ get {
172+ try {
173+ Send ( RequestMethod . GET , "/name" ) ;
174+ return true ;
175+ } catch ( Errors . StaleElementReferenceError ) {
176+ return false ;
177+ }
178+ }
179+ }
180+
167181 /// <summary>
168182 /// Gets the attribute value.
169183 /// </summary>
@@ -184,6 +198,15 @@ public object CssValue(string property) {
184198 return value ;
185199 }
186200
201+ /// <summary>
202+ /// Returns the value attribute
203+ /// </summary>
204+ /// <returns></returns>
205+ public object Value ( ) {
206+ var value = Send ( RequestMethod . GET , "/attribute/value" ) ;
207+ return value ;
208+ }
209+
187210 /// <summary>
188211 /// Gets the screenshot of the current element
189212 /// </summary>
@@ -198,11 +221,13 @@ public Image TakeScreenshot(int delayms = 0) {
198221 }
199222
200223 var dict = ( Dictionary ) _session . javascript . Execute (
201- "return arguments[0].getBoundingClientRect()" , new [ ] { this } , false ) ;
224+ "return arguments[0].getBoundingClientRect(); " , new [ ] { this } , false ) ;
202225
203- var rect = new System . Drawing . Rectangle (
204- Convert . ToInt32 ( dict [ "left" ] ) , Convert . ToInt32 ( dict [ "top" ] ) ,
205- Convert . ToInt32 ( dict [ "width" ] ) , Convert . ToInt32 ( dict [ "height" ] ) ) ;
226+ int left = Convert . ToInt32 ( dict [ "left" ] ) ;
227+ int top = Convert . ToInt32 ( dict [ "top" ] ) ;
228+ int width = Convert . ToInt32 ( dict [ "width" ] ) ;
229+ int height = Convert . ToInt32 ( dict [ "height" ] ) ;
230+ var rect = new System . Drawing . Rectangle ( left , top , width , height ) ;
206231
207232 using ( Image image = ( Image ) _session . Send ( RequestMethod . GET , "/screenshot" ) ) {
208233 var bitmap = image . GetBitmap ( ) ;
@@ -321,11 +346,13 @@ public void ReleaseKeys(string modifiers) {
321346 _session . keyboard . KeyUp ( modifiers ) ;
322347 }
323348
349+
324350 /// <summary>
325351 /// Simulates typing into the element.
326352 /// </summary>
327353 /// <param name="keysOrModifier">Sequence of keys or a modifier key(Control,Shift...) if the sequence is in keysToSendEx</param>
328354 /// <param name="keys">Optional - Sequence of keys if keysToSend contains modifier key(Control,Shift...)</param>
355+ /// <returns></returns>
329356 /// <example>
330357 /// To Send mobile to an element :
331358 /// <code lang="vbs">
@@ -367,6 +394,17 @@ public void Click(string keys = null) {
367394 _session . keyboard . SendKeys ( keys ) ;
368395 }
369396
397+ /// <summary>
398+ /// Scrolls the current element into the visible area of the browser window.
399+ /// </summary>
400+ public WebElement ScrollIntoView ( bool alignTop = false ) {
401+ string script = "arguments[0].scrollIntoView("
402+ + ( alignTop ? "true);" : "false);" ) ;
403+ object [ ] arguments = { this } ;
404+ _session . javascript . Execute ( script , arguments , false ) ;
405+ return this ;
406+ }
407+
370408 #endregion
371409
372410
@@ -576,6 +614,14 @@ public WebElement WaitDisplayed(bool displayed = true, int timeout = -1) {
576614 return this ;
577615 }
578616
617+ /// <summary>
618+ /// Wait for the web element to be removed from the DOM.
619+ /// </summary>
620+ /// <param name="timeout"></param>
621+ public void WaitRemoval ( int timeout = - 1 ) {
622+ _session . SendUntil ( timeout , ( ) => this . IsPresent , ( r ) => r ) ;
623+ }
624+
579625 #endregion
580626
581627
@@ -606,6 +652,12 @@ public TableElement AsTable() {
606652 /// <param name="script">The JavaScript code to execute.</param>
607653 /// <param name="arguments">The arguments to the script.</param>
608654 /// <returns>The value returned by the script.</returns>
655+ /// <example>
656+ /// <code lang="vbs">
657+ /// Set element = driver.FindElementById("id")
658+ /// Debug.Print element.ExecuteScript("return [this.tagName, this.scrollLeft, this.scrollTop];")
659+ /// </code>
660+ /// </example>
609661 public object ExecuteScript ( string script , object arguments = null ) {
610662 string newscript = "return (function(){" + script + "}).apply(arguments[0],arguments[1]);" ;
611663 object [ ] newargs = FormatArguments ( this , arguments ) ;
0 commit comments