@@ -1951,21 +1951,6 @@ class Window {
19511951 new command . Command ( command . Name . GET_WINDOW_RECT )
19521952 )
19531953 } catch ( ex ) {
1954- if ( ex instanceof error . UnknownCommandError ) {
1955- let { width, height } = await this . driver_ . execute (
1956- new command . Command ( command . Name . GET_WINDOW_SIZE ) . setParameter (
1957- 'windowHandle' ,
1958- 'current'
1959- )
1960- )
1961- let { x, y } = await this . driver_ . execute (
1962- new command . Command ( command . Name . GET_WINDOW_POSITION ) . setParameter (
1963- 'windowHandle' ,
1964- 'current'
1965- )
1966- )
1967- return { x, y, width, height }
1968- }
19691954 throw ex
19701955 }
19711956 }
@@ -1995,26 +1980,6 @@ class Window {
19951980 } )
19961981 )
19971982 } catch ( ex ) {
1998- if ( ex instanceof error . UnknownCommandError ) {
1999- if ( typeof x === 'number' && typeof y === 'number' ) {
2000- await this . driver_ . execute (
2001- new command . Command ( command . Name . SET_WINDOW_POSITION )
2002- . setParameter ( 'windowHandle' , 'current' )
2003- . setParameter ( 'x' , x )
2004- . setParameter ( 'y' , y )
2005- )
2006- }
2007-
2008- if ( typeof width === 'number' && typeof height === 'number' ) {
2009- await this . driver_ . execute (
2010- new command . Command ( command . Name . SET_WINDOW_SIZE )
2011- . setParameter ( 'windowHandle' , 'current' )
2012- . setParameter ( 'width' , width )
2013- . setParameter ( 'height' , height )
2014- )
2015- }
2016- return this . getRect ( )
2017- }
20181983 throw ex
20191984 }
20201985 }
@@ -2653,6 +2618,36 @@ class WebElement {
26532618 )
26542619 }
26552620
2621+ /**
2622+ * Get the value of the given attribute of the element.
2623+ * <p>
2624+ * This method, unlike {@link #getAttribute(String)}, returns the value of the attribute with the
2625+ * given name but not the property with the same name.
2626+ * <p>
2627+ * The following are deemed to be "boolean" attributes, and will return either "true" or null:
2628+ * <p>
2629+ * async, autofocus, autoplay, checked, compact, complete, controls, declare, defaultchecked,
2630+ * defaultselected, defer, disabled, draggable, ended, formnovalidate, hidden, indeterminate,
2631+ * iscontenteditable, ismap, itemscope, loop, multiple, muted, nohref, noresize, noshade,
2632+ * novalidate, nowrap, open, paused, pubdate, readonly, required, reversed, scoped, seamless,
2633+ * seeking, selected, truespeed, willvalidate
2634+ * <p>
2635+ * See <a href="https://w3c.github.io/webdriver/#get-element-attribute">W3C WebDriver specification</a>
2636+ * for more details.
2637+ *
2638+ * @param attributeName The name of the attribute.
2639+ * @return The attribute's value or null if the value is not set.
2640+ */
2641+
2642+ getDomAttribute ( attributeName ) {
2643+ return this . execute_ (
2644+ new command . Command ( command . Name . GET_DOM_ATTRIBUTE ) . setParameter (
2645+ 'name' ,
2646+ attributeName
2647+ )
2648+ )
2649+ }
2650+
26562651 /**
26572652 * Get the given property of the referenced web element
26582653 * @param {string } propertyName The name of the attribute to query.
@@ -2721,15 +2716,7 @@ class WebElement {
27212716 new command . Command ( command . Name . GET_ELEMENT_RECT )
27222717 )
27232718 } catch ( err ) {
2724- if ( err instanceof error . UnknownCommandError ) {
2725- const { width, height } = await this . execute_ (
2726- new command . Command ( command . Name . GET_ELEMENT_SIZE )
2727- )
2728- const { x, y } = await this . execute_ (
2729- new command . Command ( command . Name . GET_ELEMENT_LOCATION )
2730- )
2731- return { x, y, width, height }
2732- }
2719+ throw err ;
27332720 }
27342721 }
27352722
0 commit comments