Skip to content
This repository has been archived by the owner. It is now read-only.

Element is not currently visible and may not be manipulated exception #11637

Open
skov555 opened this issue Sep 23, 2013 · 79 comments

Comments

@skov555
Copy link

commented Sep 23, 2013

Simple code in selenium works in both Firefox driver and HtmlUnit driver but it
fails with PhantomJs as it returns element not visible exception.

Steps.

  1. Go to page https://signup.live.com/
  2. Select element by id iBirthDay
  3. Set value by value
@fraogongi

This comment has been minimized.

Copy link

commented Oct 8, 2013

I get the same problem. I have a form with just two input fields. Works perfectly OK in Firefox and other browsers, but when using PhantomJS, I get an

"InvalidElementStateException: Message: u'Error Message => 'Element is not currently interactable and may not be manipulated"

I can clearly see the the input elements are present when I take a screenshot via selenium functions.

Is this an issue with PhantomJS itself?

@simon-k

This comment has been minimized.

Copy link

commented Oct 21, 2013

Have the same problem. Using Coypu. When running in Firefox everything works fine, but in PhantomJS I get a ElementNotVisibleException when I try to sumulate a link click.

From screenshots I can see that the link is visible.

@Fak3

This comment has been minimized.

Copy link

commented Oct 23, 2013

Same problem with pahntomjs version 1.9.2.
To reproduce - navigate to the same page twice, then try to click visible element
webdriver.get(url)
webdriver.get(url)
webdriver.find('#my_elem').click()

raises ElementNotVisibleException: 'Element is not currently visible and may not be manipulated'

@TheNorthEestern

This comment has been minimized.

Copy link

commented Oct 28, 2013

I'm also encountering this issue (works fine in Firefox, chokes in PhantomJS) using WebDriver with Python

Here's the snippet in question:

driver.execute_script("window.scrollTo("+ str(selected_sites_textbox_location['x']) + ","+ str(selected_sites_textbox_location['y']) +");")

for site_name in site_names:
     for num_placements in range(scraper.conf['sites'][site_name]):
           # Code chokes here.
           selected_sites_textbox.send_keys(site_name)
           sleep(2)
           selected_sites_textbox.send_keys(Keys.RETURN)
@shankisg

This comment has been minimized.

Copy link

commented Nov 8, 2013

Same for me, works on Firefox but not working with PhantomJS.
"phantomjs ElementNotVisibleException: Message: u'Error Message => 'Element is not currently visible and may not be manipulated"

@shankisg

This comment has been minimized.

Copy link

commented Nov 8, 2013

Hi guys, I just found a solution. Try this
browser = webdriver.PhantomJS()
browser.set_window_size(1124, 850) # set browser size.
browser.get("http:example.com") # Load page

The solution is we need to set a fake browser size before doing browser.get("").

Hope this helps

@skov555

This comment has been minimized.

Copy link
Author

commented Nov 8, 2013

I was setting window, so it will not solve my issue. I am taking screenshot and I can see element there but it still will give this error when I try to change value of that element.

@Synesso

This comment has been minimized.

Copy link

commented Nov 11, 2013

I set the window to maximize and the problem persisted. Looking at the screenshot though it was only 400px wide. The element was visible, but on a hunch I set the screen dimensions to exactly 1024px wide and the test passed.

@simplexx

This comment has been minimized.

Copy link

commented Dec 8, 2013

I also have this problem and i have an idea why it's happening. It seems like when there is a div, (which is always visible and does not scroll) (Like on the live.com website), The displayed property for this div is true, but for all other elements on that page, it is false.

@nchagrass

This comment has been minimized.

Copy link

commented Dec 11, 2013

I also have this problem, resizing the window does fix it.

Thanks to @ShankiG

@skov555

This comment has been minimized.

Copy link
Author

commented Dec 11, 2013

Resizing or changing window size is not fixing it. In your case it is not a issue but you just did not set window size correctly. Issue is when you have window set up and on screen shot you can see element but browser reports it as invisible.

@TheNorthEestern

This comment has been minimized.

Copy link

commented Dec 11, 2013

Resizing the window seems to have remedied the issue for me, but this isn't really a fix, considering the original script ran fine without a hitch in Firefox without having to resize the window.

@simplexx

This comment has been minimized.

Copy link

commented Dec 11, 2013

Like i said, this problem occurs on certain websites when there is a div, which is fixed and always visible. check https://signup.live.com/

@shankisg

This comment has been minimized.

Copy link

commented Dec 13, 2013

Hi guys, I have tried a lot with different ways to solve the issue. But resizing the window was the last option available to me.

@mokies

This comment has been minimized.

Copy link

commented Jan 7, 2014

I am experiencing this issue with clearly visible radio buttons. Tests run fine in Firefox but fail in phantonjs, the page resize work around does not resolve the issue for me.

@micurley

This comment has been minimized.

Copy link

commented Jan 23, 2014

Was just running into this issue myself
process was clearing text input value then entering new value
changed driver.clear() to driver.clear w/o parens and works fine

@jdewit

This comment has been minimized.

Copy link

commented Feb 7, 2014

using protractor.js, setting window size fixed this error. thanks @ShankiG

driver.manage().window().setSize(1000, 800);

@macdonjo

This comment has been minimized.

Copy link

commented Feb 17, 2014

Calling: element.clear before using element.set_keys works for me! Thanks micurley.

@Saren-Arterius

This comment has been minimized.

Copy link

commented Feb 20, 2014

Thanks @ShankiG
browser.set_window_size(1440, 900) # Fixes "Element is not currently interactable and may not be manipulated" in PhantomJS 1.9.7

@nishannakarmi

This comment has been minimized.

Copy link

commented Jul 28, 2014

Thanks @ShankiG
browser.set_window_size(1120, 550) works

@mjhea0

This comment has been minimized.

Copy link

commented Aug 25, 2014

Thanks @ShankiG

from selenium import webdriver
driver = webdriver.PhantomJS()
driver.set_window_size(1120, 550)
driver.get("https://duckduckgo.com/")
driver.find_element_by_id('search_form_input_homepage').send_keys("realpython")
driver.find_element_by_id("search_button_homepage").click()
print driver.current_url
driver.quit()
@lacymorrow

This comment has been minimized.

Copy link

commented Sep 3, 2014

A different fix that worked for me was to set the elementScrollBehavior (desired) capability. Changing from the default (0) to 1 will cause Selenium to scroll target elements to the bottom of the page instead of the top.
These correspond to the behaviors of the JavaScript scrollIntoView() function.

It will work any fixed elements at the top of the page.

Found at https://code.google.com/p/selenium/issues/detail?id=5764

@lhridley

This comment has been minimized.

Copy link

commented Jan 30, 2015

Encountered the same issue with PhantomJS (1.9.7) , CasperJS (1.1.beta3) and PhantomCSS. Using a casper.click() or a casper.mouse.click() on a tag element that is clearly visible and clickable via a media query in a CSS3 stylesheet in a browser at screen sizes below 940px (css style --> display: block) but is hidden on larger screens (css style: display: none) generates the same error:

error: "CasperError: No element matching selector found: a#megamenu-button-mobile"

stack: in getElementBounds() in /usr/local/casperjs/modules/casper.js:1039

in computeCenter() in /usr/local/casperjs/modules/mouse.js:56
in processEvent() in /usr/local/casperjs/modules/mouse.js:78
in click() in /usr/local/casperjs/modules/mouse.js:97
in anonymous() in test/homepage.js:115
in anonymous() in test/homepage.js:147
in _forEach() in /usr/local/casperjs/modules/casper.js:621

Error does not occur with SlimerJS (0.9), CasperJS (1.1.beta3) and PhantomCSS.

Elements are visible and clickable in Firefox, Safari and Chrome.

@tit

This comment has been minimized.

Copy link

commented May 5, 2015

require 'selenium-webdriver'

driver = Selenium::WebDriver.for :phantomjs
driver.manage.window.resize_to 1920, 1080

Work! Thanx!

@RamyaBNayak

This comment has been minimized.

Copy link

commented Jun 6, 2015

Setting the window size or maximize fixed the issue.
driver.Manage().Window.Maximize();

Thanks @ShankiG

@mirraj2

This comment has been minimized.

Copy link

commented Jun 14, 2015

Setting the window size didn't work for me, but calling driver.manage().window().maximize() DID work.

@furqi01

This comment has been minimized.

Copy link

commented Jun 14, 2015

Hey Guys!
This issue is due to the following reasons:
i) Duplicated element locators for e.g (identical cssSelectors, Xpath etc.)
ii) You are trying to access an element that is hidden and not visible.

For resolution of first reason, you need to write unique cssSelector/xpath etc. that only locate the required element.

For resolution of 2nd, you can use explicit wait and wait till the element is not visible. Once it is visible then you can perform your operations.
Syntax: new WebDriverWait(driver, 30).until(ExpectedConditions.visibilityOfElementLocated(By.xpath/cssSelector("your path here")));

The third solution that would really works for you in any case is to take the size of the identical elements, and then locating the exact element for you using this:

int ok_size=driver.findElements(By.xpath/cssSelector("your path herel")).size();
driver.findElements(By.xpath/cssSelector("your path here']")).get(ok_size-1).click();

You can set "ok_size-1" or "ok_size-2" depending upon your requirement i-e which place element you want to locate either on first place or second place or so.

I will recommend this third solution to all as it really works for me in all the cases.
Cheers!

@A1rPun

This comment has been minimized.

Copy link

commented Jun 30, 2015

Thank you for the real answer @furqi01 . Resolved my issue.

@furqi01

This comment has been minimized.

Copy link

commented Jun 30, 2015

my pleasure @A1rPun :)

@raneyvik

This comment has been minimized.

Copy link

commented Aug 17, 2015

Hello All,

I have tried to automate airtel website (https://business.airtel.in/escares/) using phantomjs executable and its working,

But when I am trying to run it on Linux Server.I have installed Phantom Js 1.9.8 on redhat linux box and trying to run the class.Its showing
"Element is currently not intractable and may not be manipulated"

I have tried setting the window size as well..Setted several sizes but no luck.

Could any1 please tell me how to resolve this issue.I am stuck from quite a long time.

@Nunna09

This comment has been minimized.

Copy link

commented May 26, 2016

i am having the same issue, non of these suggestions helped me, already tried different browser sizes, and also maximizing. the strange thing is when i creating a screesnhot, everything is visible, but i cant click on the element, and even stranger that when i am getting the source code before the element click part, i am getting the code from the previous "window". (i am loading a new iframe when click on the next button on the prev page).

may you have any suggestions?

I have the same issue as ZILAHIR. Tried all the things posted in here. Can somebody suggest the fix please..?

@furqi01

This comment has been minimized.

Copy link

commented May 26, 2016

@Nunna09 can you provide the URL and steps to perform that actions?
May be then I can help..

@Nunna09

This comment has been minimized.

Copy link

commented May 26, 2016

@furqi01, actually the issue is with the object as it is unable to identify. And the cause is every time I run the test it picks up the website from the cache so it does not need to open the sub window and actually performing the action. But in my test I have given xpath to find the sub window.

Thanks furgi01.

@Nunna09

This comment has been minimized.

Copy link

commented May 26, 2016

its resolved now

@furqi01

This comment has been minimized.

Copy link

commented May 26, 2016

cool!

@Nunna09

This comment has been minimized.

Copy link

commented May 26, 2016

Hi

can anyone give the links for headless browser testing and phantomjs documentation ..?
I am doing POC for my new project and I need to highlight few points.
Any help must be appreciated.

Thanks,
Nunna

@mikeatlas

This comment has been minimized.

Copy link

commented Jun 22, 2016

Encountered this with Agouti (Go / Golang) and PhantomJS. Solution to resize the window worked for me:

    window, err := page.Session().GetWindow()
    Expect(err).To(BeNil())
    window.SetSize(1920, 1080)

This resolved "Element is not currently visible" issues when trying to interact with an element (e.g., click it).

@gabernardone

This comment has been minimized.

Copy link

commented Jul 15, 2016

This worked for me
driver.Manage().Window.Maximize();

jkytomak added a commit to Opetushallitus/haku that referenced this issue Aug 10, 2016
fixes LomakeIT test on PhantomJS.
preference1-reset button was not found because:
ariya/phantomjs#11637
jkytomak added a commit to Opetushallitus/haku that referenced this issue Aug 11, 2016
fixes LomakeIT test on PhantomJS.
preference1-reset button was not found because:
ariya/phantomjs#11637
alexGofore added a commit to Opetushallitus/haku that referenced this issue Aug 15, 2016
fixes LomakeIT test on PhantomJS.
preference1-reset button was not found because:
ariya/phantomjs#11637
@tyleralves

This comment has been minimized.

Copy link

commented Oct 12, 2016

thanks @shankisg

@vaskort

This comment has been minimized.

Copy link

commented Oct 21, 2016

What helped me in my case to have consistent results in PhantomJS is to scroll to the element you want to interact before setting its value for instance:

var emailInput = browser.element('#emailInput');
browser.scroll('#emailInput');
emailInput.setValue('test@test.com');

I use WebdriverIO

@kag0

This comment has been minimized.

Copy link

commented Dec 3, 2016

same issue, selenium java 3.0.1, phantom 2.1.1, resizing window does not help.

@mrtamb9

This comment has been minimized.

Copy link

commented Dec 5, 2016

Thanks @ShankiG, resize window helps me.

@fallenprogrammr

This comment has been minimized.

Copy link

commented Feb 21, 2017

It seems like setting a window size and maximizing the window is required to make phantomjs webdriver actually be able to interact with the elements. This is the code that worked for me (python):

driver.set_window_size(1120, 550)
driver.maximize_window()

@subhojit777

This comment has been minimized.

Copy link

commented Mar 10, 2017

I had to click an element, and it gave this error. For me neither resizing or maximizing the window worked. I fixed it by executeScript().

$this->session->executeScript('jQuery("' . $selector . '").click()');
@aniquetahir

This comment has been minimized.

Copy link

commented Mar 25, 2017

@furqi01 didn't expect to see you here _

@nesttle

This comment has been minimized.

Copy link

commented May 3, 2017

Same issue here with PhantomJS
https://accounts.google.com/signin/v2/identifier?flowName=GlifWebSignIn&flowEntry=ServiceLogin
(April-May/2017 :: Google Login V2)

Element is not currently visible and may not be manipulated

@mrased

This comment has been minimized.

Copy link

commented May 3, 2017

@nesttle
Hi, I found the same issue there, while tried to automate the new gmail URL login:
I have found a solution :

Executed on Chrome: Version 58.0.3029.96
Logic: The password field is untraceable until "Enter your password" label is visible in the box on password validation field.

Please try this piece of code to implement same logic in other browsers too.:

WebDriverWait wait = new WebDriverWait(driver,5 );

wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//*[@id='password']/div[1]/div/div[1]/div")));
driver.findElement(By.xpath("//*[@id='password']/div[1]/div/div[1]/input")).sendKeys("password");
driver.findElement(By.xpath("//*[@id='passwordNext']/content/span")).click();

Thanks,

@nesttle

This comment has been minimized.

Copy link

commented May 3, 2017

@mrased thanks for your reply!

Anyway, bad news for me, since II'm facing issues with your snippet too.
Something went wrong.
image

(PhantomJS 2.1.0 binary + py)

email_element = WebDriverWait(self.driver, 30).until(EC.presence_of_element_located((By.ID, "identifierId")))
email_element.click()
email_element.clear()
time.sleep(3)
email_element.send_keys(self.parnt.username)
time.sleep(5)
nextone = WebDriverWait(self.driver, 30).until(EC.presence_of_element_located((By.ID, "identifierNext")))
nextone.click()
time.sleep(5)
WebDriverWait(self.driver, 30).until(EC.presence_of_element_located((By.XPATH, "//*[@id='password']/div[1]/div/div[1]/div")))
self.driver.find_element_by_xpath("//*[@id='password']/div[1]/div/div[1]/input").send_keys(self.parnt.password)
self.driver.find_element_by_xpath("//*[@id='passwordNext']/content/span").click()
time.sleep(5)
@mrased

This comment has been minimized.

Copy link

commented May 4, 2017

@nesttle Sad to hear that this logic is not feasible for py.
Definitely I will try to implement in py as followed by java .

I have tried to find the rc for "Some thing went wrong" message.
Came up with following four scenarios:
1.Network congestion
2.Link failure
3. Element dislocation
4.Element not loaded.

Need some time for behavior inspection of the link.

@developez

This comment has been minimized.

Copy link

commented May 31, 2017

In .NET, something like this solves the issue:

driver.Manage().Window.Size = new System.Drawing.Size(1920, 1080);

@dturchenko91

This comment has been minimized.

Copy link

commented Jun 29, 2017

I have a potential solution that may work for some of you. Like many of you, my code worked fine with ChromeDriver and FirefoxDriver but failed on PhantomJS.

Neither resizing the window nor fluent waits solved my problem. The target element was always marked invisible on phantom js no matter what.

What worked for me was to use a selenium action to move the mouse to the element and click.

new Actions(driver).moveToElement( driver.findElement(By.cssSelector("div.choose_submit>button>h4"))).click().perform();

@aescalana

This comment has been minimized.

Copy link

commented Oct 10, 2017

I was experiencing the same issue with PhantomJS version 2.1.1, Python 2.7 and Selenium 3.6.0.

Much like @fraogongi, I could clearly see that the elements I was trying to manipulate were visible when I saved a screenshot.

Just like @Fak3 pointed out, I had this issue when I loaded the same page twice. I was doing this in order to inject cookies. My code looked something like this:

#!/usr/bin/env python
from selenium import webdriver

url = 'https://some.page.com'
cssSelector = '#elementID'
cookies = loadCookies()

driver = webdriver.PhantomJS()

print 'Loading page'
driver.get(url)

print 'Injecting cookies'
driver.delete_all_cookies()
for cookie in cookies:
  driver.add_cookie(cookie)

print 'Reloading page with injected cookies'
driver.get(url)

element = driver.find_element_by_css_selector(cssSelector)

print 'Clicking history link'
element.click() # raises ElementNotVisibleException

print driver.title

driver.quit()

I did something similar to what @shankisg suggested. I maximized the window of the driver after its creation and that solved it:

driver = webdriver.PhantomJS()
driver.maximize_window()
@VladoPortos

This comment has been minimized.

Copy link

commented Nov 7, 2017

Still not solved ? I have the same issue, I get all the links from page and when I want to click on random one I will usually get this error :( I have tried the maximize_window and such... with no luck :(

@gjoerg

This comment has been minimized.

Copy link

commented Nov 9, 2017

Hi folks, I get the same errorMessage: Element is not currently interactable and may not be manipulated

  • tried to size the window to 1920 x 1080
  • tried to fix the multiple elements, but i locate by xpath and there is only one in the list
  • tried to maximize()
  • tried also to move the mouse via Actions.moveToElement

and also tried all together, but nothing seems to fix it... Am really stuck here, has someone another idea?

os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.10.5', java.version: '1.8.0_51'
selenium-java
3.7.1

phantomjsdriver
1.4.1

if it helps: i try to send keys or click this element:

<input name="filter_message_number" id="filter_message_number" class="k-textbox input_medium_big_2" placeholder="international, z.Bsp.: 436761234567" value="" type="text">

i locate it like that:

driver2.findElement(By.xpath("//input[@id='filter_message_number']")).sendKeys(number);

Thanks, help would be appreciated!

@gjoerg

This comment has been minimized.

Copy link

commented Nov 15, 2017

Hi folks, me again.

Solved it for me with Actions (org.openqa.selenium.interactions.Actions)

new Actions(driver2).moveToElement(driver2.findElement(By.xpath("//input[@id='filter_message_number']"))).sendKeys(number).perform();

Like that it works for me. Hope it helps for one or another.

Peace and out :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
You can’t perform that action at this time.