Element not visible in firefox as well as chrome - java

I am working in selenium webdriver 2.0, and I have to automate a script for running functional and cross-browser testing. I am getting an error of element not visible when I am trying to click on an element with the class .divAdvSearchFeildListName&[data-id='30001'] for a drop down.
The same code works fine for some drop-downs to select a country name and jurisdiction from the same page on the same page. The error I am getting is:
org.openqa.selenium.ElementNotVisibleException: Element is not currently visible and so may not be interacted with
Command duration or timeout: 47 milliseconds
Build info: version: '2.32.0', revision: '6c40c18', time: '2013-04-09 17:22:56'
System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1', java.version: '1.7.0_21'
Session ID: 2ca283f6-5703-4ef6-b07f-2dee99b531ab
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{platform=XP, databaseEnabled=true, cssSelectorsEnabled=true, javascriptEnabled=true, acceptSslCerts=true, handlesAlerts=true, browserName=firefox, browserConnectionEnabled=true, nativeEvents=true, webStorageEnabled=true, rotatable=false, locationContextEnabled=true, applicationCacheEnabled=true, takesScreenshot=true, version=22.0}]
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:187)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:554)
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:268)
at org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:79)
at com.anteambulo.SeleniumJQuery.Prog_Try_Six.automate(Prog_Try_Six.java:1112)
at com.anteambulo.SeleniumJQuery.Prog_Try_Six.hCueIgn(Prog_Try_Six.java:122)
at com.anteambulo.SeleniumJQuery.Prog_Try_Six.main(Prog_Try_Six.java:71)
Caused by: org.openqa.selenium.remote.ErrorHandler$UnknownServerException: Element is not currently visible and so may not be interacted with
Build info: version: '2.32.0', revision: '6c40c18', time: '2013-04-09 17:22:56'
System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1', java.version: '1.7.0_21'
Driver info: driver.version: unknown
at <anonymous class>.fxdriver.preconditions.visible(file:///C:/DOCUME~1/155366/LOCALS~1/Temp/anonymous8998336689581680973webdriver-profile/extensions/fxdriver#googlecode.com/components/command_processor.js:7682)
at <anonymous class>.DelayedCommand.prototype.checkPreconditions_(file:///C:/DOCUME~1/155366/LOCALS~1/Temp/anonymous8998336689581680973webdriver-profile/extensions/fxdriver#googlecode.com/components/command_processor.js:10402)
at <anonymous class>.DelayedCommand.prototype.executeInternal_/h(file:///C:/DOCUME~1/155366/LOCALS~1/Temp/anonymous8998336689581680973webdriver-profile/extensions/fxdriver#googlecode.com/components/command_processor.js:10421)
at <anonymous class>.DelayedCommand.prototype.executeInternal_(file:///C:/DOCUME~1/155366/LOCALS~1/Temp/anonymous8998336689581680973webdriver-profile/extensions/fxdriver#googlecode.com/components/command_processor.js:10426)
at <anonymous class>.DelayedCommand.prototype.execute/<(file:///C:/DOCUME~1/155366/LOCALS~1/Temp/anonymous8998336689581680973webdriver-profile/extensions/fxdriver#googlecode.com/components/command_processor.js:10366)
My code gets stuck at line number 6 in this code snippet. As you can see in the code I am trying to highlight that web element with a 5px solid yellow border:
jQuery EntitySearchTypeValue = browser.queryUntil(a1ValEntityDropDownList);
setCellName(26,0,a1ValEntityDropDownListLabel,sheetReportGeneration);
hCueExcel(1,1,26,sheetReportGeneration,browser,colNoForDiffBrowsers,EntitySearchTypeValue);
System.out.println("Login Button found");
// password.css("border", "none");
EntitySearchTypeValue.css("border", "5px solid yellow");
takescreenshot(a1ValFileNamePath,26,colNoForDifferentScreenShots,sheetSnapshotGeneration,workbook);
***EntitySearchTypeValue.get().click();***
// browser.findElement(By.className("divAdvSearchFeildListName&[data-id='30001']")).click();
// browser.getDrv().findElementByClassName("EntitySearchTypeValue&[data-id='30001']").click();
// browser.getDrv().findElementByCssSelector(".divAdvSearchFeildListName&[data-id='30001']").click();
// document.querySelector(".field[data-test]");
// browser.get()
// By cssSelector = By.cssSelector(".field[data-test='testytest']");
// or By.cssSelector(".field[data-test=testytest]")
// or By.cssSelector(".field[data-test]")
//bin.findElement(cssSelector).sendKeys("Hello");
try{
Thread.sleep(5000L);
}catch(Exception e){
}
The same code works fine in Firefox, but gets stuck at some point later in the code for other browsers. For Chrome it gets stuck in the beginning for the third drop-down in the same page. I have the selenium-server-standalone-2.32.0.jar which is the latest version.

This exception means that the element you are trying to click on is hidden. Make sure that the element is visible before click on it. You can add a wait if the element becomes visible after delay.
Apart from this you should check the system configuration and it should be compatible.

Related

How to click post button in Facebook groups?, webdriver Java

I also cannot click this button with the below code, i've tried:
driver.navigate().to(groupname);
Thread.sleep(3000);
driver.findElement(By.name("xhpc_message_text")).sendKeys(LinkYT+"\n");
Thread.sleep(3000);
driver.findElement(By.xpath("\\button\\span[.=\"Post\"]")).click();
I've used also waits and cssSelectors but cannot manage to click the button. I'm surely doing something wrong
Do you you have a suggestion?
<button class="_1mf7 _4jy0 _4jy3 _4jy1 _51sy selected _42ft" data-
testid="react-composer-post-button" type="submit" value="1"><img alt=""
class="_3-8_ _5gm4 img"
src="https://www.facebook.com/rsrc.php/v3/yb/r/GsNJNwuI-UM.gif" data-
testid="react-composer-throbber" width="16" height="11"><span
class="">Post</span></button>
ex for one of my tries, all have same no such element exection. so xpath,css selector etc i get them wrong for this button...
Exception in thread "main" org.openqa.selenium.NoSuchElementException: no
such element: Unable to locate element:
{"method":"xpath","selector":"//button[#type='submit']
[contains(text(),'Post')]"}
(Session info: chrome=61.0.3163.100)
(Driver info: chromedriver=2.30.477700
(0057494ad8732195794a7b32078424f92a5fce41),platform=Windows NT 10.0.15063
x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 46 milliseconds
For documentation on this error, please visit:
http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
System info: host: 'INTERN2017-37', ip: '10.6.220.24', os.name: 'Windows
10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_131'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false,
mobileEmulationEnabled=false, networkConnectionEnabled=false, chrome=
{chromedriverVersion=2.30.477700 (0057494ad8732195794a7b32078424f92a5fce41),
userDataDir=C:\Users\LUCIAN~1.PAT\AppData\Local\Temp\scoped_dir19996_28709},
takesHeapSnapshot=true, pageLoadStrategy=normal, databaseEnabled=false,
handlesAlerts=true, hasTouchScreen=false, version=61.0.3163.100,
platform=XP, browserConnectionEnabled=false, nativeEvents=true,
acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true,
browserName=chrome, takesScreenshot=true, javascriptEnabled=true,
cssSelectorsEnabled=true, unexpectedAlertBehaviour=}]
Session ID: 2bbb3a860bbafbca888b4a9c5af20029
*** Element info: {Using=xpath, value=//button[#type='submit']
[contains(text(),'Post')]}
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
manged to do it with:
WebElement elem = driver.findElement(By.xpath("//button[#type='submit']//span[contains(text(),'Post')]"));
Actions actions = new Actions(driver);
actions.moveToElement(elem).click().perform();
Your answer is correct but as I guess you can also use xpath using SPAN directly like this
WebElement elem = driver.findElement(By.xpath("//span[contains(text(),'Post')]"));
Actions actions = new Actions(driver);
actions.moveToElement(elem).click().perform();

How to fix “Permission denied to access property "invoke”"?

Code -
Select Gender = new Select(driver.findElement(By.xpath("//select[#id='gender']")));
Gender.selectByValue("Male");
Error -
`Exception in thread "main" org.openqa.selenium.WebDriverException: **Permission denied to access property "invoke"**
Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
System info: host: 'COMP2-PC', ip: '192.168.1.9', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_91'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{rotatable=false, raisesAccessibilityExceptions=false, appBuildId=20161123182536, version=50.0.1, platform=XP, proxy=Proxy(), command_id=1.0, specificationLevel=0.0, acceptSslCerts=false, processId=2380.0, browserVersion=50.0.1, platformVersion=6.1, XULappId={ec8030f7-c20a-464f-9b0e-13a3a9e97384}, browserName=firefox, takesScreenshot=true, takesElementScreenshot=true, javascriptEnabled=true, platformName=windows_nt}] Session ID: c1e4da76-9f21-45aa-a1b8-f21a9e8dd088
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException
(W3CHttpResponseCodec.java:150)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode
(W3CHttpResponseCodec.java:115)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode
(W3CHttpResponseCodec.java:45)
at org.openqa.selenium.remote.HttpCommandExecutor.execute
(HttpCommandExecutor.java:164)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute
(DriverCommandExecutor.java:82)
at org.openqa.selenium.remote.RemoteWebDriver.execute
(RemoteWebDriver.java:637)
at org.openqa.selenium.remote.RemoteWebElement.execute
(RemoteWebElement.java:272)
at org.openqa.selenium.remote.RemoteWebElement.getAttribute
(RemoteWebElement.java:124)
at org.openqa.selenium.support.ui.Select.<init>(Select.java:52)
at AppInformationTest.main(AppInformationTest.java:70) `
While trying to automate (Selecting a dropdown value) with selenium webdriver I ran into this problem.
Tools Versions are*:
Java - 1.8.0_91,
Eclipse - Oxygen Release (4.7.0),
Mozilla Firefox-50.01,
Gecko driver-v0.17.0-win64 ....Please help me to sort out!
It is browser specfic issue , try it with Chrome. Follow this link to see more
Reference Link for your issue

org.openqa.selenium.StaleElementReferenceException: Element is no longer attached to the DOM

I'm getting "StaleElementReferenceException" when selecting an option from the dropdown and get it as string. I'm very disappointed with the issue for last two days and I didn't get any best suggestion to sort out my issue. I'm very new to selenium, Please help me to sort out this issue.
public static WebElement prepProduct(WebDriver driver) throws InterruptedException
{
WebDriverWait wait = new WebDriverWait(driver,20);
Boolean enable=driver.findElement(By.xpath(".//*[#id='batch-update-prep-owner']")).isEnabled();
if(enable.TRUE)
{
Select whoPrepsMerchant= new Select(driver.findElement(By.xpath(".//*[#id='prep-items']/tr[2]/td[5]/select")));
whoPrepsMerchant.selectByIndex(new Random().nextInt(whoPrepsMerchant.getOptions().size()));
String merchant=whoPrepsMerchant.getFirstSelectedOption().getText();
Thread.sleep(3000);
String whoPrepsvalue=(driver.findElement(By.xpath(".//*[#id='prep-items']/tr[2]/td[7]/span"))).getText();
System.out.println("outer");
if(merchant.equalsIgnoreCase("Amazon"))
{
System.out.println("inner");
if(!whoPrepsvalue.equalsIgnoreCase("--"))
{
System.out.println("innerone");
Thread.sleep(3000);
driver.findElement(By.xpath(".//*[#id='continue-plan']")).click();
}
}
else
{
if(whoPrepsvalue.equalsIgnoreCase("--"))
{
System.out.println("innertwo");
Thread.sleep(3000);
driver.findElement(By.xpath(".//*[#id='continue-plan']")).click();
}
}
}
else
{
Thread.sleep(3000);
driver.findElement(By.xpath(".//*[#id='continue-plan']")).click();
}
return element;
}
Error Log:
org.openqa.selenium.StaleElementReferenceException: Element is no longer attached to the DOM
Command duration or timeout: 15 milliseconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/stale_element_reference.html
Build info: version: '3.0.0-beta4', revision: '3169782', time: '2016-09-29 10:29:23 -0700'
System info: host: '7531HY1', ip: '10.45.183.77', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_111'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{applicationCacheEnabled=true, rotatable=false, handlesAlerts=true, databaseEnabled=true, version=45.4.0, platform=WINDOWS, nativeEvents=false, acceptSslCerts=true, webStorageEnabled=true, locationContextEnabled=true, browserName=firefox, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]
Session ID: 2eb3cd2b-e2e0-4efb-8b4c-3eb08f00ed45
*** Element info: {Using=tag name, value=option}
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:636)
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:284)
at org.openqa.selenium.remote.RemoteWebElement.findElements(RemoteWebElement.java:203)
at org.openqa.selenium.remote.RemoteWebElement.findElementsByTagName(RemoteWebElement.java:280)
at org.openqa.selenium.By$ByTagName.findElements(By.java:327)
at org.openqa.selenium.remote.RemoteWebElement.findElements(RemoteWebElement.java:179)
at org.openqa.selenium.support.ui.Select.getOptions(Select.java:70)
at org.openqa.selenium.support.ui.Select.getFirstSelectedOption(Select.java:94)
at NAGamma.SellerCentralPOM.prepProduct(SellerCentralPOM.java:85)
at NAGamma.Regression.main(Regression.java:40)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:100)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:646)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:811)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1137)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:129)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:112)
at org.testng.TestRunner.privateRun(TestRunner.java:753)
at org.testng.TestRunner.run(TestRunner.java:607)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:368)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:363)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:321)
at org.testng.SuiteRunner.run(SuiteRunner.java:270)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1284)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1209)
at org.testng.TestNG.runSuites(TestNG.java:1124)
at org.testng.TestNG.run(TestNG.java:1096)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:236)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:81)
Caused by: org.openqa.selenium.StaleElementReferenceException: Element is no longer attached to the DOM
For documentation on this error, please visit: http://seleniumhq.org/exceptions/stale_element_reference.html
Build info: version: '3.0.0-beta4', revision: '3169782', time: '2016-09-29 10:29:23 -0700'
System info: host: '7531HY1', ip: '10.45.183.77', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_111'
Driver info: driver.version: unknown
at <anonymous class>.fxdriver.cache.getElementAt(resource://fxdriver/modules/web-element-cache.js:9531)
at <anonymous class>.Utils.getElementAt(file:///C:/Users/kesavamp/AppData/Local/Temp/anonymous980588199586178216webdriver-profile/extensions/fxdriver#googlecode.com/components/driver-component.js:9916)
at <anonymous class>.FirefoxDriver.prototype.findElementsInternal_(file:///C:/Users/kesavamp/AppData/Local/Temp/anonymous980588199586178216webdriver-profile/extensions/fxdriver#googlecode.com/components/driver-component.js:11205)
at <anonymous class>.FirefoxDriver.prototype.findChildElements(file:///C:/Users/kesavamp/AppData/Local/Temp/anonymous980588199586178216webdriver-profile/extensions/fxdriver#googlecode.com/components/driver-component.js:11226)
at <anonymous class>.DelayedCommand.prototype.executeInternal_/h(file:///C:/Users/kesavamp/AppData/Local/Temp/anonymous980588199586178216webdriver-profile/extensions/fxdriver#googlecode.com/components/command-processor.js:12698)
at <anonymous class>.DelayedCommand.prototype.executeInternal_(file:///C:/Users/kesavamp/AppData/Local/Temp/anonymous980588199586178216webdriver-profile/extensions/fxdriver#googlecode.com/components/command-processor.js:12703)
at <anonymous class>.DelayedCommand.prototype.execute/<(file:///C:/Users/kesavamp/AppData/Local/Temp/anonymous980588199586178216webdriver-profile/extensions/fxdriver#googlecode.com/components/command-processor.js:12645)
Try this
Declare at the global level
WebDriverWait wait = new WebDriverWait(driver, 5);
Before selecting option from Drop-down
// while the following loop runs, the DOM changes -
// page is refreshed, or element is removed and re-added
wait.until(presenceOfElementLocated(By.id("container-element")));
// now we're good - let's click the element
For selecting option from Drop-down.
driver.findElement(By.id("foo")).click();
You can use:
wait.until(ExpectedConditions.refreshed(ExpectedConditions.visibilityOf(Element)));
Please verify and let me know if this is working fine for you...

Java Selenium Webdriver: Element not clickable

I tried verifying an element present onpage using isDisplayed()
it returns true.
Tried Actions class and JavascriptExecutor but no luck
Able to find an element but it is not clickable.
org.openqa.selenium.WebDriverException: unknown error: Element is not clickable at point (48, 339). Other element would receive the click: <div modal-render="true" tabindex="-1" role="dialog" class="modal fade ng-isolate-scope ng-animate ng-leave ng-leave-active" uib-modal-animation-class="fade" modal-in-class="in" ng-style="{'z-index': 1050 + index*10, display: 'block'}" uib-modal-window="modal-window" size="md" index="0" animate="animate" modal-animation="true" data-ng-animate="2" style="z-index: 1050; display: block;">...</div>
(Session info: chrome=51.0.2704.103)
(Driver info: chromedriver=2.7.236900,platform=Windows NT 6.3 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 68 milliseconds
Build info: version: '2.53.0', revision: '35ae25b1534ae328c771e0856c93e187490ca824', time: '2016-03-15 10:43:46'
os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_91'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false, chrome=takesHeapSnapshot=true, databaseEnabled=false, handlesAlerts=true, version=51.0.2704.103, platform=XP, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]
Session ID: 58f38b1bcae44097a4dad7378ba32e35
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678)
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:327)
at org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:85)
There's a DIV modal in the way of the click. It's explained in the error message. Dismiss it or otherwise handle it.
Try to use ExpectedConditions from WebDriverWait class to check the Clickable property of the element.
Many a time I have seen that element.isDisplayed/isEnabled didn't work, but this worked fine.
Eg Code:
Webdriver driver;
WebDriverWait wait = new WebDriverWait(driver, 15);
wait.until(ExpectedConditions.elementToBeClickable(By.className("xyz"))).click();

Current IE doesn't support file upload using Selenium Webdriver 2.42.000

Currently I was able to upload the file using selenium webdriver version 2.42.00 with browser chrome while I couldn't able to do it the same with Internet Explorer version 11.
driver.findElement(By.id("fileUpload")).sendKeys(filePath);
where id = fileUpload is for input element with type=file and this field is a hidden field.
Any thoughts on it:
org.openqa.selenium.ElementNotVisibleException: Element is not displayed (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 30 milliseconds
Build info: version: '2.44.0', revision: '76d78cf323ce037c5f92db6c1bba601c2ac43ad8', time: '2014-10-23 13:11:40'
System info: host: 'XXXXXXX', ip: '192.168.12.24', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.8.0_40'
Driver info: org.openqa.selenium.ie.InternetExplorerDriver
Capabilities [{browserAttachTimeout=0, enablePersistentHover=false, ie.forceCreateProcessApi=false, ie.usePerProcessProxy=false, ignoreZoomSetting=false, handlesAlerts=true, version=11, platform=WINDOWS, nativeEvents=true, ie.ensureCleanSession=false, elementScrollBehavior=0, ie.browserCommandLineSwitches=, requireWindowFocus=true, browserName=internet explorer, initialBrowserUrl=http://localhost:7704/ takesScreenshot=true, javascriptEnabled=true, ignoreProtectedModeSettings=false, enableElementCacheCleanup=true, cssSelectorsEnabled=true, unexpectedAlertBehaviour=dismiss}]
Session ID: cfa81fae-4ea2-43b9-9e3a-69135462fe82
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_40]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) ~[na:1.8.0_40]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) ~[na:1.8.0_40]
It is a known issue with IEDriver which is going to be resolved in next release. Hidden file input tag will not work on IE as it does on other browsers. See the issue logged here. I have answered a similar question here
EDIT
Here is the good news. Just confirmed the Selenium version 2.46 has the changes. See changelog. So upgrade and it should work

Categories