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.
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?
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.
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'
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)
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"
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
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.
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.
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.
I also have this problem, resizing the window does fix it.
Thanks to @shankig
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.
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.
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/
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.
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.
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
using protractor.js, setting window size fixed this error. thanks @shankig
driver.manage().window().setSize(1000, 800);
Calling: element.clear before using element.set_keys works for me! Thanks micurley.
Thanks @shankig
browser.set_window_size(1440, 900) # Fixes "Element is not currently interactable and may not be manipulated" in PhantomJS 1.9.7
Thanks @shankig
browser.set_window_size(1120, 550) works
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()
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
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"
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.
require 'selenium-webdriver'
driver = Selenium::WebDriver.for :phantomjs
driver.manage.window.resize_to 1920, 1080
Work! Thanx!
Setting the window size or maximize fixed the issue.
driver.Manage().Window.Maximize();
Thanks @shankig
Setting the window size didn't work for me, but calling driver.manage().window().maximize() DID work.
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!
Thank you for the real answer @furqi01 . Resolved my issue.
my pleasure @A1rPun :)
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.
I'm using PhantomJS 1.9 on Ubuntu 14.04 and I have the same issue. I've tried everything got get PhantomJS to click an element that's in a dropdown list. The browser does not perform ActionChains for me like Firefox and Chrome, so I then tried using pure clicks. Once again Firefox and Chrome work great but PhantomJS still gives me:
"Element is not currently interactable and may not be manipulated"
I've taken furqi01 's advice and followed it closely and it still doesn't work.
@ozbrancov: can you provide the script here?
Setting the window size or maximize fixed the issue.
driver.manage().wndow.maximize();
Thanks @shankisg
I have the same issue, can't process following site https://www.mycommerce.com/affiliate-login on CentOS 5.8 and PhantomJS 1.9.8
After this java command:
WebElement usernameInput = mainDriver.findElement(By.name("PUBLISHER_ID"));
I have a following error:
Caused by: org.openqa.selenium.remote.ErrorHandler$UnknownServerException: {"errorMessage":"Element is not currently interactable and may not be manipulated","request":{"headers":{"Accept":"application/json, image/png","Connection":"Keep-Alive","Content-Length":"49","Content-Type":"application/json; charset=utf-8","Host":"localhost:7727"},"httpVersion":"1.1","method":"POST","post":"{"id":":,"url":"/value","urlParsed":{"anchor":"","query":"","file":"value","directory":"/","path":"/value","relative":"/value","port":"","host":"","password":"","user":"","userInfo":"","authority":"","protocol":"","source":"/value","queryKey":{},"chunks":["value"]},"urlOriginal"......}}
PhantomJS 1.9.8 can't process this site :(
How to fix it ?
P.S.
setSize()/maximize() also doesn't work
@Artgit You can try by introducing an implicit wait and before the command and then locate the element by xpath using this command:
mainDriver.manage().timeouts().implicitlyWait(100, TimeUnit.SECONDS);
WebElement usernameInput = mainDriver.findElement(By.xpath(".//*[@id='ClientLoginShareIt']/div[1]/div[1]/input"));
After reviewing the above issue it seems like it's having difficulty to locate the element. So in my opinion if you introduced an implicit wait and then locate the element using xpath (commands written above) then it would help to resolve this issue.
Let me know if you find this helpful.
@furqi01 Thanks for your answer !
Unfortunately the same issue. It can locate element but fails on the following line(Sorry, I was wrong in my previous post.. this is the same line as previously.. it fails on the sendKeys method ):
usernameInput.sendKeys(USERNAME);
Caused by: org.openqa.selenium.remote.ErrorHandler$UnknownServerException: {"errorMessage":"Element is not currently interactable and may not be manipulated"
I don't know why but PhantomJS 1.9.8 on CentOS 5.8 can't properly render this site.. this is a screenshot:
@Artgit so you need to resolve this issue of rendering the page completely and to me this is home page snapshot where there is no Paricipant ID field like on login page.
Another thing, are you using some ad blockers type extensions? Seems like you are using some ad blockers which are enabled and causing the page not to render completely.
Disable such extensions and then run the test. Hopefully, it would work!
Let me know if this helps you.
@furqi01 this a screenshot of a login page .. the same story..
Also, I don't use any adblocks.
hmm..quite strange...I can reproduce the same by enabling browser ad-ons/extensions actually.
I don't know how to check these add-ons on CentOS 5.8.. will dig into it
I think this issue related to SSL.. :
Connecting to cdn.mycommerce.com|54.240.184.105|:443... connected.
OpenSSL: error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure
How to disable SSL validation on PhantomJS side ?
@Artgit
alright..then do try this. Below command will help you resolve the SSL related issue:
phantomjs --ignore-ssl-errors=yes [phantomOptions] script.js [scriptOptions]
Here is a complete list of command line options for phantomjs is available here: http://phantomjs.org/api/command-line.html.
I hope this helps.
I have tried different combination of :
capabilities.setCapability(PhantomJSDriverService.PHANTOMJS_CLI_ARGS, new String[] {"--ssl-protocol=any", "--web-security=false", "--ignore-ssl-errors=true"});
Right now, I think this issue related to tlsv1.2
Does PhantomJS support tlsv1.2 ?
Nopz.
You can go through this thread: https://github.com/ariya/phantomjs/issues/13496
Well.. is it possible to inject external css files to the loaded page via PhantomJS ? I can manually download css files from this site and inject it into the page on the fly.. Will it work ?
In case, someone encounters this issue in nodejs running selenium-webdriver and phantomjs 2.1.1, the following work around worked for me.
Due to webdriver's asynchronous nature, one needs to handle the browser 'resize' within the returned promise's success callback. i.e :
driver.get(URL).then(function () {
driver.manage().window().maximize();
});
I have the same issue ...i am using webdriver + groovy....NOTHING helped me.........:(
For me I was facing the same issue in one of my project, what I was able to get the element and able to enter the text in Selenium code, but not with phantom JS and serenity framework, I did focus on the element using this: ((JavascriptExecutor)driver).executeScript("document.getElementById('ELEMENT_ID').focus());
This worked for me.
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?
@zilahir can you check that the element on which you want to click is in an iframe or the element locator is not unique for that element? or what error you are getting in the console?
@furqi01 before the clicking the desired element, i am unselecting the prev frame, and then selecting the current one. this step passes. but then, the click returns:
ValueError: Element locator '//*[@id="print_ok"]' did not match any elements.
@zilahir thank you!
Have you introduced any conditional wait?
or if you can try another thing, that enter this xpath in firepath using firefox and check if it's locating the element their, just to confirm that xpath doesn't have any issues.
This worked for me
browser.setViewportSize({
width: 1920,
height: 1080
});
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..?
@Nunna09 can you provide the URL and steps to perform that actions?
May be then I can help..
@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.
its resolved now
cool!
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
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).
This worked for me
driver.Manage().Window.Maximize();
thanks @shankisg
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('[email protected]');
_I use WebdriverIO_
same issue, selenium java 3.0.1, phantom 2.1.1, resizing window does not help.
Thanks @shankig, resize window helps me.
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()
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()');
@furqi01 didn't expect to see you here _
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
@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,
@mrased thanks for your reply!
Anyway, bad news for me, since II'm facing issues with your snippet too.
Something went wrong.
(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)
@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
Need some time for behavior inspection of the link.
In .NET, something like this solves the issue:
driver.Manage().Window.Size = new System.Drawing.Size(1920, 1080);
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();
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()
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 :(
Hi folks, I get the same errorMessage: Element is not currently interactable and may not be manipulated
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'
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!
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 :)
Due to our very limited maintenance capacity (see #14541 for more details), we need to prioritize our development focus on other tasks. Therefore, this issue will be automatically closed. In the future, if we see the need to attend to this issue again, then it will be reopened. Thank you for your contribution!
Most helpful comment
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