"isDisplayed" method returns false when element has CSS property "position: absolute" .
Meta -
OS: Ubuntu 16.04 LTS 64 bit
Selenium Version: 3.4.0
Browser: Chrome Version 61.0.3163.79 (Official Build) (64-bit)
Browser Version: 61.0.3163.79 (Official Build) (64-bit)
Expected Behavior -
Element(having CSS property "position: absolute") is displayed in the View Port, isDisplayed method should return true
Actual Behavior -
Element(having CSS property "position: absolute") is displayed in the View Port, isDisplayed method should returns false
Steps to reproduce -
Try isDisplayed method on any WebElement having CSS property "position: absolute" visible inside the viewport
This is working fine for me, so we'll need a more specific reproducible case.
from selenium.webdriver import Chrome
driver = Chrome()
driver.get('https://the-internet.herokuapp.com/checkboxes')
el = driver.find_element_by_css_selector('input[type="checkbox"]')
driver.execute_script('arguments[0].style = "position: absolute";', el)
print(el.is_displayed())
driver.quit()
If you open this website https://elisa.fi there is webelement with classname called "elisa-navi__login__links", it is the top navigation in the top right corner, this element opens if you press the link which says "Kirjaudu"(login in english).
Works fine for me. Are you sure you're waiting for the menu to become visible after clicking on "Kirjaudu"? It's not instant but the code will be. See code (python):
from selenium.common.exceptions import TimeoutException
from selenium.webdriver import Chrome
from selenium.webdriver.remote.webdriver import By
from selenium.webdriver.support.expected_conditions import visibility_of_element_located
from selenium.webdriver.support.ui import WebDriverWait
menu_css ='.elisa-navi__login__links'
driver = Chrome()
driver.get('https://elisa.fi/')
print(driver.find_element_by_css_selector(menu_css).is_displayed())
driver.find_element_by_css_selector('span.login-name').click()
try:
menu = WebDriverWait(driver, 3, .5).until(visibility_of_element_located([By.CSS_SELECTOR, menu_css]))
print('is displayed)
except TimeoutException:
print('not displayed')
driver.quit()
Closed accidentally.
Yeah, i am waiting for the element to be visible.
You still haven't given a reproducible scenario. Unless you do, we'll have to close this.
Can you try this in Scala, because my testcase is in scala, i wonder if that(coding language) has to do anything with it.
Try what? Please provide a reporoduction scenario in scala, it's acceptable too.
Please provide a reporoduction scenario, otherwise the issue will be closed.
Closing the issue as there is no known way to reproduce it.
Similar issue can be reproduced with the following page: https://www.waze.com/livemap
Python code example:
`from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC browser = webdriver.Chrome('./chromedriver') browser.get('https://www.waze.com/livemap') if name == 'main': WebDriverWait(browser, delay).until( EC.presence_of_element_located((By.XPATH, "//input[@class='wm-search__input']"))) text_area = browser.find_element_by_xpath("//input[@class='wm-search__input']")
#Element it's already visible after loading, but tried to hide it and show it again: browser.execute_script("var x = document.getElementsByClassName('wm-search__input');$(x[1]).hide();") time.sleep(.5) browser.execute_script("var x = document.getElementsByClassName('wm-search__input');$(x[1]).show();") browser.execute_script('arguments[0].style = "position: absolute";', text_area)
if text_area.is_displayed(): print("is_displayed= True") else: print("is_displayed= False")
browser.quit() ` Issue: The element "wm-search__input" is visible in the browser, but variable "is_displayed" keep's returning False.