selenium icon indicating copy to clipboard operation
selenium copied to clipboard

"isDisplayed" method returns false when element has CSS property "position: absolute" .

Open john007abhilash opened this issue 9 years ago • 11 comments

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

john007abhilash avatar Sep 28 '17 13:09 john007abhilash

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()

lmtierney avatar Sep 28 '17 14:09 lmtierney

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).

john007abhilash avatar Sep 29 '17 07:09 john007abhilash

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()

lmtierney avatar Sep 29 '17 13:09 lmtierney

Closed accidentally.

lmtierney avatar Sep 29 '17 13:09 lmtierney

Yeah, i am waiting for the element to be visible.

john007abhilash avatar Sep 29 '17 13:09 john007abhilash

You still haven't given a reproducible scenario. Unless you do, we'll have to close this.

lmtierney avatar Sep 29 '17 13:09 lmtierney

Can you try this in Scala, because my testcase is in scala, i wonder if that(coding language) has to do anything with it.

john007abhilash avatar Oct 02 '17 09:10 john007abhilash

Try what? Please provide a reporoduction scenario in scala, it's acceptable too.

barancev avatar Oct 02 '17 09:10 barancev

Please provide a reporoduction scenario, otherwise the issue will be closed.

barancev avatar Oct 12 '17 15:10 barancev

Closing the issue as there is no known way to reproduce it.

barancev avatar Oct 18 '17 11:10 barancev

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.

johnofsaints avatar Aug 24 '18 07:08 johnofsaints