This should work:
.//button[.='OK' and not(ancestor::div[contains(@style,'display:none')])
and not(ancestor::div[contains(@style,'display: none')])]
EDIT:
The simpler and more efficient expression below:
//div[not(contains(@style,'display:none'))]//button[.='OK']
does not work properly because every button has at least one div that’s visible in its ancestors.
More Related Contents:
- StaleElementException when iterating with Python
- XPath: difference between dot and text()
- ElementNotVisibleException: Message: element not interactable error while trying to click a button through Selenium and Python
- Exception in thread “main” org.openqa.selenium.NoSuchElementException: Unable to locate element: //*[@id=’login-email’]
- Selenium not able to click on Get Data button on using Python
- How to verify an XPath expression in Chrome Developers tool or Firefox’s Firebug?
- selenium.common.exceptions.ElementClickInterceptedException: Message: element click intercepted: Element is not clickable with Selenium and Python
- How to solve the error “Not a valid XPath expression”
- Select parent element of known element in Selenium
- GWT module may need to be (re)compiled REDUX
- Python Selenium – get href value
- ElementClickInterceptedException: Message: element click intercepted: Element is not clickable with Selenium and Python
- Date time library for gwt
- ‘UnexpectedTagNameException’ and Element should have been “select” but was “div” error using ‘Select’ function through Selenium java
- How to retrieve partial text from a text node using Selenium and Python
- Creating XPATH for svg tag
- ElementNotInteractableException: Message: element not interactable error sending text in search field using Selenium Python
- selenium two xpath tests in one
- How to select the auto suggestion from the dynamic dropdown using Selenium and Java
- What is the difference between a CSS selector and XPath? And which is better with respect to performance for cross-browser testing?
- How to find element by part of its id name in selenium with python
- What is the difference between a CSS and XPath selector? And which is better with respect to performance for cross-browser testing?
- Difference between “//” and “/” in XPath?
- Using an OR condition in Xpath to identify the same element
- Using the GWT Scheduler
- How to wait for either of the two elements in the page using selenium xpath
- GWT.setUncaughtExceptionHandler()
- Using GWT Editors with a complex usecase
- Is string matches() supported in Selenium Webdriver 2?
- How to click on Load More button within Google Trends and print all the titles through Selenium and Python