Selenium Webdriver - findElement atom issue - selenium

SELENIUM WEBDRIVER - IE
I'm trying to click on a link by using the following command:
driver.findElement(By.linkText("Previous orders")).click();
and I'm getting this error ... I could make it work some times but most of the time I get this error, it's intermitent, any ideas?
> Started InternetExplorerDriver server (32-bit)
2.50.0.0
Listening on port 25630
Only local connections are allowed
Exception in thread "main" org.openqa.selenium.WebDriverException: A JavaScript error was encountered executing the findElement atom. (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 46 milliseconds
Build info: version: '2.50.1', revision: 'd7fc91b', time: '2016-01-29 19:04:49'
System info: host: 'ABC598-L1BCDL9', ip: 'xxx.xxx.xxx.xxx', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_71'
Driver info: org.openqa.selenium.ie.InternetExplorerDriver
Capabilities [{browserAttachTimeout=0, enablePersistentHover=true, ie.forceCreateProcessApi=false, pageLoadStrategy=normal, ie.usePerProcessProxy=false, ignoreZoomSetting=false, handlesAlerts=true, version=11, platform=WINDOWS, nativeEvents=true, ie.ensureCleanSession=false, elementScrollBehavior=0, ie.browserCommandLineSwitches=, requireWindowFocus=false, browserName=internet explorer, initialBrowserUrl=http://localhost:25630/, takesScreenshot=true, javascriptEnabled=true, ignoreProtectedModeSettings=false, enableElementCacheCleanup=true, cssSelectorsEnabled=true, unexpectedAlertBehaviour=dismiss}]
Session ID: 9865fcae-fa06-46b5-a621-d8390978c515
*** Element info: {Using=link text, value=Previous orders}
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.RemoteWebDriver.findElement(RemoteWebDriver.java:363)
at org.openqa.selenium.remote.RemoteWebDriver.findElementByLinkText(RemoteWebDriver.java:428)
at org.openqa.selenium.By$ByLinkText.findElement(By.java:246)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:355)
at Test.main(Test.java:27)
Main Code:
import java.util.concurrent.TimeUnit;
import javax.swing.JOptionPane;
import org.openqa.selenium.Alert;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.security.UserAndPassword;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.Select;
import org.openqa.selenium.support.ui.WebDriverWait;
public class Test {
public static void main(String[] args) throws InterruptedException {
String cartId = JOptionPane.showInputDialog("Type the Cart ID:");
System.setProperty("webdriver.ie.driver",
"C:\\Users\\USER_ADMIN\\Downloads\\Selenium Webdriver\\IEDriverServer.exe");
DesiredCapabilities returnCapabilities = DesiredCapabilities.internetExplorer();
returnCapabilities.setCapability(InternetExplorerDriver.ENABLE_PERSISTENT_HOVERING, false);
WebDriver driver = new InternetExplorerDriver(returnCapabilities);
driver.manage().timeouts().implicitlyWait(120, TimeUnit.SECONDS);
driver.get("https://k06proxy012.sby.com/procurement/buyondemand/common/enUS/index.html");
driver.findElement(By.linkText("Log in to Buy on demand (Bond)")).click();
login(driver);
// START
driver.findElement(By.linkText("Previous orders")).click();
driver.findElement(By.linkText("Search previous orders")).click();
new Select(driver.findElement(By.id("FIELD1"))).selectByVisibleText("Cart ID");
driver.findElement(By.id("VALUE1")).clear();
driver.findElement(By.id("VALUE1")).sendKeys(cartId);
driver.quit();
}
public static void login(WebDriver driver) {
WebDriverWait wait = new WebDriverWait(driver, 10);
Alert alert = wait.until(ExpectedConditions.alertIsPresent());
alert.authenticateUsing(new UserAndPassword("user", "pass"));
}
}

Try to turn protected mode on IE
Click/tap on tools on the menu bar, and Internet Options
In the Security tab, select every zone and turn off protected mode
else can you write the main's code

I don't think the error is caused by erroneous code on your part. I tried upgrading to IEDriverServer 2.50 today and started receiving the same error. I returned to using 2.48 as a temporary workaround. Other newer versions may work between the two, this is just what I used previously.
Also see this recent issue on the project's Github page: https://github.com/SeleniumHQ/selenium/issues/1590

It seems that i found the reproducable case.
Check this issue https://github.com/SeleniumHQ/selenium/issues/2421
The point is in this javascript instruction:
var Number="рпоп";
Note, that if you write "number" (first small letter) - it will be working.
It seems the problem is in incorrect javascript code parsing.

Related

Not able to click on link obtain using findElements method

this is just a simple code to obtain all links from a particular section of a web page; click on those links get the title and return back to the parent page and repeat process for next one. But after clicking on 2 links I am getting error "stale element reference: element is not attached to the page document" Please refer code and let me know what I am missing.
I am able to open links in a new tab and get the title of child pages. But I want to open a link in the same tab.
package test;
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
public class LinkTest {
public static void main (String[] args) throws InterruptedException{
System.setProperty("webdriver.chrome.driver", "C:\\ChromeDriver\\1\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("http://www.qaclickacademy.com/practice.php");
WebElement driverFooter = driver.findElement(By.xpath("//div[#id='gf-BIG']"));
WebElement footerC1 = driverFooter.findElement(By.xpath("//table/tbody/tr/td/ul[1]"));
List<WebElement> links = footerC1.findElements(By.tagName("a"));
for(int i=0;i<links.size();i++){
links.get(i).click();
System.out.println(driver.getTitle());
driver.navigate().back();
}
}
}
It should open all links and get the title and return to parent page for next iterator. Below is output and error,
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
[1550488224.725][WARNING]: Timed out connecting to Chrome, retrying...
Practice Page
REST API Tutorial
Exception in thread "main" org.openqa.selenium.StaleElementReferenceException: stale element reference: element is not attached to the page document
(Session info: chrome=72.0.3626.109)
(Driver info: chromedriver=2.46.628402 (536cd7adbad73a3783fdc2cab92ab2ba7ec361e1),platform=Windows NT 10.0.16299 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 6 milliseconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/stale_element_reference.html
Build info: version: '2.53.0', revision: '35ae25b', time: '2016-03-15 17:00:58'
System info: host: 'DS-SGH631RNL8', ip: '10.118.59.16', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_201'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{mobileEmulationEnabled=false, timeouts={implicit=0, pageLoad=300000, script=30000}, hasTouchScreen=false, platform=XP, acceptSslCerts=false, goog:chromeOptions={debuggerAddress=localhost:53075}, acceptInsecureCerts=false, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, setWindowRect=true, unexpectedAlertBehaviour=ignore, applicationCacheEnabled=false, rotatable=false, networkConnectionEnabled=false, chrome={chromedriverVersion=2.46.628402 (536cd7adbad73a3783fdc2cab92ab2ba7ec361e1), userDataDir=C:\Users\RUSHIK~1.KAD\AppData\Local\Temp\scoped_dir11700_2428}, takesHeapSnapshot=true, pageLoadStrategy=normal, strictFileInteractability=false, databaseEnabled=false, handlesAlerts=true, version=72.0.3626.109, browserConnectionEnabled=false, proxy={}, nativeEvents=true, locationContextEnabled=true, cssSelectorsEnabled=true}]
Session ID: e1a6bdd0b525d1c6e1d940a2ec156e51
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)
at test.LinkTest.main(LinkTest.java:23)
You are getting StaleElementReferenceException which comes when the element you are trying to access is no longer available in the dom or has become stale, to correct it you need to pick the elements again and then operate on it. You can modify your code like:
System.setProperty("webdriver.chrome.driver", "C:\\ChromeDriver\\1\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("http://www.qaclickacademy.com/practice.php");
WebElement driverFooter = driver.findElement(By.xpath("//div[#id='gf-BIG']"));
WebElement footerC1 = driverFooter.findElement(By.xpath("//table/tbody/tr/td/ul[1]"));
List<WebElement> links = footerC1.findElements(By.tagName("a"));
for(int i=0;i<links.size();i++){
driverFooter = driver.findElement(By.xpath("//div[#id='gf-BIG']"));
footerC1 = driverFooter.findElement(By.xpath("//table/tbody/tr/td/ul[1]"));
List<WebElement> newLinks = footerC1.findElements(By.tagName("a"));
newLinks.get(i).click();
System.out.println(driver.getTitle());
driver.navigate().back();
driver.navigate().refresh();
}

Unable to click the element. Error: no such element: Unable to locate element:

I am practicing on flipkart.com. i am unable to click the product after the search result. The xpath is correct. I tried using scroll function,visible, find by partial linktext, wait, sleep still i am unable to do. Please find the below code.
package Flipkart;
import org.openqa.selenium.By; import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class TC2
{
public static void main(String[] args) throws InterruptedException
{
System.setProperty("webdriver.chrome.driver","C:\\Chrome\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("https://www.flipkart.com/");
driver.findElement(By.name("q")).sendKeys("Bag");
driver.findElement(By.xpath("html/body/div[1]/div/header/div[1]/div[2]/div/div/div[2]/form/div/div[2]/button")).click();
driver.findElement(By.xpath(".//*[#id='container']/div/div[2]/div[2]/div/div[2]/div/div[3]/div[1]/div[1]/div[1]/div/a[2]")).click();
}
}
Error:
Starting ChromeDriver 2.25.426923 (0390b88869384d6eb0d5d09729679f934aab9eed) on port 17575
Only local connections are allowed.
Exception in thread "main" org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":".//*[#id='container']/div/div[2]/div[2]/div/div[2]/div/div[3]/div[1]/div[1]/div[1]/div/a[2]"}
(Session info: chrome=58.0.3029.81)
(Driver info: chromedriver=2.25.426923 (0390b88869384d6eb0d5d09729679f934aab9eed),platform=Windows NT 10.0.14393 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 76 milliseconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
System info: host: 'D90T0CQ1', ip: '192.168.162.83', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_102'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, networkConnectionEnabled=false, chrome={chromedriverVersion=2.25.426923 (0390b88869384d6eb0d5d09729679f934aab9eed), userDataDir=C:\Users\SALUNK~1\AppData\Local\Temp\scoped_dir12552_16506}, takesHeapSnapshot=true, pageLoadStrategy=normal, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=58.0.3029.81, platform=XP, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]
Session ID: a8c3432c9b1e8cce3365db9407fc310f
*** Element info: {Using=xpath, value=.//*[#id='container']/div/div[2]/div[2]/div/div[2]/div/div[3]/div[1]/div[1]/div[1]/div/a[2]}
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:678)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:363)
at org.openqa.selenium.remote.RemoteWebDriver.findElementByXPath(RemoteWebDriver.java:500)
at org.openqa.selenium.By$ByXPath.findElement(By.java:361)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:355)
at Flipkart.TC2.main(TC2.java:15)
Here is the Answer to your Question:
I don't see any such errors/issues in your code. A few words about the solution:
Chrome browser sometimes doesn't opens maximized so you need to maximize the Chrome browser using ChromeOptions class.
If the browser is not maximized certain elements doesn't appers within the Viewport and and may throw NoSuchElementException
Add the argument to disable the infobars through ChromeOptions class.
Your xpath looks vulnerable to me, try to construct logical xpath for the elements on the HTML DOM.
Your own code works at my end with some simple tweaks which opens the Chrome
Browser, navigates to the URL https://www.flipkart.com/, searches for Bag, clicks on Skybags Pixel Plus 03 30 L Backpack and Skybags Pixel Plus 03 30 L Backpack (Grey) is opened in a new tab.
Here is the modified code block:
System.setProperty("webdriver.chrome.driver","C:\\your_directory\\chromedriver.exe");
ChromeOptions options = new ChromeOptions();
options.addArguments("start-maximized");
options.addArguments("disable-infobars");
WebDriver driver = new ChromeDriver(options);
driver.get("https://www.flipkart.com/");
driver.findElement(By.name("q")).sendKeys("Bag");
driver.findElement(By.xpath("html/body/div[1]/div/header/div[1]/div[2]/div/div/div[2]/form/div/div[2]/button")).click();
driver.findElement(By.xpath(".//*[#id='container']/div/div[2]/div[2]/div/div[2]/div/div[3]/div[1]/div[1]/div[1]/div/a[2]")).click();
Let me know if this Answers your Question.
I have tried the same lines of code which you have mentioned and things work for me. Maybe you should try again.
Please try to use small xpath:
Suggestion:
Replace Xpath: html/body/div[1]/div/header/div[1]/div[2]/div/div/div[2]/form/div/div[2]/button with the different Xpath:
//form[#action="/search"]/div/div[2]/button
You should use relative path instead of absolute path because if there are any changes made in the path of the element then that XPath gets failed.
I got the same exception and added implicitly wait. It is working fine now. The code
System.setProperty("webdriver.chrome.driver",System.getProperty("user.dir") + "\\lib\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.get("https://www.flipkart.com/");
driver.findElement(By.name("q")).sendKeys("Bag");
driver.findElement(By.xpath("html/body/div[1]/div/header/div[1]/div[2]/div/div/div[2]/form/div/div[2]/button")).click();
driver.findElement(By.xpath("//*[#class='_2cLu-l']")).click();`
Final solution and I can't suggest more than this,
//openChromeBrowser();
driver.get("https://www.flipkart.com/");
driver.findElement(By.name("q")).sendKeys("Bag");
driver.findElement(By.xpath("//form[#action='/search']/div/div[2]/button")).click();
Thread.sleep(5000);
driver.findElement(By.linkText("Puma PUMA Zipper Backpack 26 L Laptop Backpack")).click();
1> Give some wait time and it works
2> Use LinkText for locators for any of the item shown.
And follow what #Monika Singhal has said for quick and efficient results in Automation.

Permission denied to access property "H"

I have written the below code to capture the entire screen shot of a webpage using java script.
I'm Using:
Firefox Version: 49.0.1
Chrome Version: 54.0.2840.59 m
Selenium Version: 3.0.0
OS: Win10 64 bit
Java: 1.8
import java.io.File;
import java.io.IOException;
import org.apache.commons.io.FileUtils;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class ScreenCapture {
public static void main(String[] args) throws IOException {
System.setProperty("webdriver.gecko.driver","C:\\Eclipse\\Drivers\\geckodriver.exe");
WebDriver driver = new FirefoxDriver();
driver.get("https://www.flipkart.com/");
driver.manage().window().maximize();
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("window.scrollTo(0, document.body.scrollHeight)");
File capture = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(capture, new File("C:\\Users\\Vishvambruth JT\\Desktop\\FlipKart.jpg"));
}
}
The webpage will scroll down but the code stops abruptly with the below error. Could you please help.
1476679740598 geckodriver INFO Listening on 127.0.0.1:38310
Oct 16, 2016 11:49:00 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Attempting bi-dialect session, assuming Postel's Law holds true on the remote end
log4j:WARN No appenders could be found for logger (org.apache.http.client.protocol.RequestAddCookies).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
1476679741083 mozprofile::profile INFO Using profile path C:\Users\VISHVA~1\AppData\Local\Temp\rust_mozprofile.h4P3qq7Ekmrz
1476679741083 geckodriver::marionette INFO Starting browser C:\Program Files (x86)\Mozilla Firefox\firefox.exe
1476679741083 geckodriver::marionette INFO Connecting to Marionette on localhost:50064
1476679742059 Marionette INFO Listening on port 50064
1476679743366 Marionette INFO startBrowser 6f833edf-0ff4-4f1f-869c-1de62f8626a9
Oct 16, 2016 11:49:03 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
Exception in thread "main" org.openqa.selenium.WebDriverException: Permission denied to access property "H"
Build info: version: 'unknown', revision: '350cf60', time: '2016-10-13 10:43:56 -0700'
System info: host: 'LAPTOP-JUUNTJIC', ip: '10.0.0.112', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_101'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{rotatable=false, raisesAccessibilityExceptions=false, marionette=true, firefoxOptions={args=[], prefs={}}, appBuildId=20160922113459, version=, platform=XP, proxy={}, command_id=1, specificationLevel=0, acceptSslCerts=false, processId=9960, browserVersion=49.0.1, platformVersion=10.0, XULappId={ec8030f7-c20a-464f-9b0e-13a3a9e97384}, browserName=firefox, takesScreenshot=true, takesElementScreenshot=true, platformName=windows_nt, device=desktop}]
Session ID: 6f833edf-0ff4-4f1f-869c-1de62f8626a9
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:127)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:93)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:42)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:163)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601)
at org.openqa.selenium.remote.RemoteWebDriver.executeScript(RemoteWebDriver.java:537)
at ScreenCapture.main(ScreenCapture.java:19)
I got the same error for Selenium Web Driver 3.0.1.
The problem was gone when switching to version 2.53.1.
I too got this issue and after some research, I can say it is not problem of Selenium. It is problem with gecko driver. You can run it with chrome and it will work fine.
Just update to Firefox Night and it will work.
The Firefox Night can be found at https://www.mozilla.org/en-US/firefox/channel/desktop/ (the one labeled Beta).
It's better to use an up-to-date webdriver version with an up-to-date Firefox Night version (all the code and efforts of development and code issues are focused on that synchronization, and of course it makes sense in order to cover newer final users scenarios better).

Unable to enter ID in twitter

I'm running the below selenium code.
import org.openqa.selenium.By;
import org.openqa.selenium.firefox.FirefoxDriver;
public class twitter {
public static void main(String[] args) throws InterruptedException {
FirefoxDriver fd = new FirefoxDriver();
fd.get("https://twitter.com/?lang=en");
Thread.sleep(2000L);
fd.findElement(By.xpath(".//*[#id='signin-email']")).sendKeys("Hello");
}
}
But i'm getting the below error.
log4j:WARN No appenders could be found for logger (org.apache.http.client.protocol.RequestAddCookies).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Exception in thread "main" org.openqa.selenium.ElementNotVisibleException: Element is not currently visible and so may not be interacted with
Command duration or timeout: 14 milliseconds
Build info: version: '2.47.1', revision: '411b314', time: '2015-07-30 02:56:46'
System info: host: 'U0138039-TPL-A', ip: '192.168.1.14', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.7.0_67'
Session ID: 96e0f5be-8e7d-402d-b7d0-2ebadc745663
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{platform=WINDOWS, acceptSslCerts=true, javascriptEnabled=true, cssSelectorsEnabled=true, databaseEnabled=true, browserName=firefox, handlesAlerts=true, nativeEvents=false, webStorageEnabled=true, rotatable=false, locationContextEnabled=true, applicationCacheEnabled=true, takesScreenshot=true, version=40.0.3}]
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:595)
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:273)
at org.openqa.selenium.remote.RemoteWebElement.sendKeys(RemoteWebElement.java:94)
at twitter.main(twitter.java:10)
Caused by: org.openqa.selenium.ElementNotVisibleException: Element is not currently visible and so may not be interacted with
Build info: version: '2.47.1', revision: '411b314', time: '2015-07-30 02:56:46'
System info: host: 'U0138039-TPL-A', ip: '192.168.1.14', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.7.0_67'
Driver info: driver.version: unknown
at <anonymous class>.fxdriver.preconditions.visible(file:///C:/Users/u0138039/AppData/Local/Temp/anonymous8514896172902827974webdriver-profile/extensions/fxdriver#googlecode.com/components/command-processor.js:9982)
at <anonymous class>.DelayedCommand.prototype.checkPreconditions_(file:///C:/Users/u0138039/AppData/Local/Temp/anonymous8514896172902827974webdriver-profile/extensions/fxdriver#googlecode.com/components/command-processor.js:12626)
at <anonymous class>.DelayedCommand.prototype.executeInternal_/h(file:///C:/Users/u0138039/AppData/Local/Temp/anonymous8514896172902827974webdriver-profile/extensions/fxdriver#googlecode.com/components/command-processor.js:12643)
at <anonymous class>.DelayedCommand.prototype.executeInternal_(file:///C:/Users/u0138039/AppData/Local/Temp/anonymous8514896172902827974webdriver-profile/extensions/fxdriver#googlecode.com/components/command-processor.js:12648)
at <anonymous class>.DelayedCommand.prototype.execute/<(file:///C:/Users/u0138039/AppData/Local/Temp/anonymous8514896172902827974webdriver-profile/extensions/fxdriver#googlecode.com/components/command-processor.js:12590)
please let me know how can i fix it.
Thaks
The problem I ran into is when I navigated to the site myself, the login panel was showing but when I did the same thing with code, the login panel was not showing. The way to get around that is to click on the "Log In" button, then enter the username/password. The code below clicks the Log In button and enters the email and password
driver.get("https://twitter.com/?lang=en");
driver.findElement(By.cssSelector("button.StreamsLogin")).click();
driver.findElement(By.id("signin-email")).sendKeys("email");
driver.findElement(By.id("signin-password")).sendKeys("password");
EDIT: For those who can't see the Log In button??? This is what I see.
I tried with JavascriptExecutor as below and it worked! It fills user name and password as foo and bar and submits.
package org;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
public class TwitterTest {
public static void main(String[] args) throws Exception {
// The Firefox driver supports javascript
WebDriver driver = new FirefoxDriver();
// driver.manage().window().maximize();
// Go to the page
driver.get("https://twitter.com/?lang=en");
WebDriverWait wait = new WebDriverWait(driver,10);
WebElement element = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[#class='front-signin js-front-signin']")));
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("document.getElementById('signin-email').value = 'foo';");
js.executeScript("document.getElementById('signin-password').value = 'bar';");
js.executeScript("document.getElementsByClassName('t1-form signin')[0].submit();");
wait.wait(10);
driver.quit(); }
}

i got the error while running javascript for IE11

below is my code :
package project1;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
public class SearchInGoogle {
public static void main(String[] args) throws InterruptedException {
System.setProperty("webdriver.ie.driver", "D:\\IEDriverServer.exe");
WebDriver driver = new InternetExplorerDriver();
driver.get("http://www.google.com");
WebElement searchBox = driver.findElement(By.name("q"));
searchBox.sendKeys("Packt Publishing");
searchBox.submit();
}
}
output:
Started InternetExplorerDriver server (32-bit)
2.29.1.0
Listening on port 17311
Exception in thread "main" org.openqa.selenium.NoSuchElementException: Unable to find element with name == q (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 296 milliseconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.42.2', revision: '6a6995d', time: '2014-06-03 17:42:30'
System info: host: 'GNRSEZDT00035', ip: '10.210.6.68', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.7.0_45'
Session ID: 00659ae5-b108-4fc4-b59c-390b1c15c879
Driver info: org.openqa.selenium.ie.InternetExplorerDriver
Capabilities [{platform=WINDOWS, elementScrollBehavior=0, javascriptEnabled=true, enablePersistentHover=true, ignoreZoomSetting=false, browserName=internet explorer, enableElementCacheCleanup=true, unexpectedAlertBehaviour=dismiss, version=11, cssSelectorsEnabled=true, ignoreProtectedModeSettings=false, requireWindowFocus=false, allowAsynchronousJavaScript=false, initialBrowserUrl=, handlesAlerts=true, nativeEvents=true, takesScreenshot=true}]
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:204)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:599)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:352)
at org.openqa.selenium.remote.RemoteWebDriver.findElementByName(RemoteWebDriver.java:425)
at org.openqa.selenium.By$ByName.findElement(By.java:299)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:344)
at project1.SearchInGoogle.main(SearchInGoogle.java:13)
I m getting the above error. The above code is able to open the page in IE11 but it is not finding any elements. I tried all elements and I already set the IE11's security settings. So do u have any other solution for this problem?