File tree Expand file tree Collapse file tree 3 files changed +46
-2
lines changed
src/browser/windows/PlaybackWindow/preload Expand file tree Collapse file tree 3 files changed +46
-2
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " @seleniumhq/selenium-ide" ,
3- "version" : " 4.0.0-alpha.11 " ,
3+ "version" : " 4.0.0-alpha.12 " ,
44 "private" : true ,
55 "description" : " Selenium IDE electron app" ,
66 "author" :
" Todd <[email protected] >" ,
Original file line number Diff line number Diff line change 1414 * limitations under the License.
1515 */
1616
17- import { parse_locator } from './utils'
17+ import { parse_locator , isVisible } from './utils'
1818import finder from '@medv/finder'
1919
2020const findElement = require ( './third-party/find-element' )
@@ -58,6 +58,18 @@ export default class LocatorBuilders {
5858 buildAll ( el : HTMLElement ) : [ string , string ] [ ] {
5959 let locator
6060 let locators : [ string , string ] [ ] = [ ]
61+
62+ let root = document . body
63+ let loopEl : HTMLElement | null = el
64+ while ( loopEl && loopEl != root ) {
65+ if ( isVisible ( loopEl ) ) {
66+ el = loopEl
67+ break
68+ } else {
69+ loopEl = loopEl . parentElement
70+ }
71+ }
72+
6173 for ( let i = 0 ; i < LocatorBuilders . order . length ; i ++ ) {
6274 let finderName = LocatorBuilders . order [ i ]
6375 try {
Original file line number Diff line number Diff line change @@ -51,3 +51,35 @@ export function getTagName(element: HTMLElement) {
5151 }
5252 return tagName
5353}
54+
55+
56+ /**
57+ * Return element is visible
58+ *
59+ * https://stackoverflow.com/questions/19669786/check-if-element-is-visible-in-dom
60+ *
61+ * @param element an HTMLElement
62+ */
63+ export function isVisible ( elem : HTMLElement ) {
64+ const style = getComputedStyle ( elem ) ;
65+ if ( style . display === 'none' ) return false ;
66+ if ( style . visibility !== 'visible' ) return false ;
67+ if ( parseFloat ( style . opacity ) < 0.1 ) return false ;
68+ if ( elem . offsetWidth + elem . offsetHeight + elem . getBoundingClientRect ( ) . height +
69+ elem . getBoundingClientRect ( ) . width === 0 ) {
70+ return false ;
71+ }
72+ const elemCenter = {
73+ x : elem . getBoundingClientRect ( ) . left + elem . offsetWidth / 2 ,
74+ y : elem . getBoundingClientRect ( ) . top + elem . offsetHeight / 2
75+ } ;
76+ if ( elemCenter . x < 0 ) return false ;
77+ if ( elemCenter . x > ( document . documentElement . clientWidth || window . innerWidth ) ) return false ;
78+ if ( elemCenter . y < 0 ) return false ;
79+ if ( elemCenter . y > ( document . documentElement . clientHeight || window . innerHeight ) ) return false ;
80+ let pointContainer : any = document . elementFromPoint ( elemCenter . x , elemCenter . y ) ;
81+ do {
82+ if ( pointContainer === elem ) return true ;
83+ } while ( ( pointContainer = pointContainer ! . parentNode ) ) ;
84+ return false ;
85+ }
You can’t perform that action at this time.
0 commit comments