Not able to check 2nd checkbox. Getting org.openqa.selenium.WebDriverException: unknown error: Element is not clickable at point (106, 655) - selenium

I am getting WebDriverException while trying to select the 2nd checkbox in the list. I am able to select the 1st check box but on the 2nd time my code throwing exception. Please find the method that i am using and exception message below.
Note: Any suggestion will be helpful for me.
URL: https://www.snapdeal.com/products/computers-external-hard-drives?sort=plrty&q=Capacity_s%3A1%20TB%7C
public void capacitySelection(String capacity){
WebDriverWait wd = new WebDriverWait(driver, 180);
List<WebElement> cList = wd.until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.xpath("//div[#data-name='Capacity_s']/div")));
int i=1;
for(WebElement we:cList){
WebElement select= wd.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//div[#data-name='Capacity_s']/div["+ i++ +"]/label")));
if(select.getText().contains(capacity)){
select.click();
break;
}
}
}
Exception Message:
Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: Element is not clickable at point (106, 655). Other element would receive the click: <label for="Capacity_s-3TB">...</label>
(Session info: chrome=54.0.2840.99)
(Driver info: chromedriver=2.24.417431 (9aea000394714d2fbb20850021f6204f2256b9cf),platform=Windows NT 6.2.9200 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 86 milliseconds
Build info: version: 'unknown', revision: '1969d75', time: '2016-10-18 09:43:45 -0700'
System info: host: 'Bishnu', ip: '192.168.0.107', os.name: 'Windows 8', os.arch: 'amd64', os.version: '6.2', java.version: '1.8.0_111'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, networkConnectionEnabled=false, chrome={chromedriverVersion=2.24.417431 (9aea000394714d2fbb20850021f6204f2256b9cf), userDataDir=C:\Users\Bishnu\AppData\Local\Temp\scoped_dir11044_5076}, takesHeapSnapshot=true, pageLoadStrategy=normal, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=54.0.2840.99, platform=WIN8, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]
Session ID: 505ec9fb429bc6b9806edb52d75856f0
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:216)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:168)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:635)
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:274)
at org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:84)
at in.prolearn.pages.HomePage.SecondCapacitySelection(HomePage.java:59)
at in.prolearn.testcases.VerifySnapDealSelection.main(VerifySnapDealSelection.java:22)
Thanks.

Can you use JavaScript instead
WebElement product = new WebDriverWait(aDriverInstance, 5L).
until(ExpectedConditions.visibilityOfElementLocatedBy(By.id("anID")));
JavascriptExecutor jsExec = (JavascriptExecutor) aDriverInstance;
jsExec.executeScript("arguments[0].scrollIntoView()", product);

Actions actions = new Actions(driver);
actions.moveToElement(select).click().perform();
Try to click the element with Actions class. This will help you.

Use .isSelected() method before performing click on that element.

Related

How to locate webelement?

I am not able to select departure city on spice jet website to check flight status.
Steps followed:
login to http://www.spicejet.com
click on flight status link
select departure city as goa from drop down>>
=====
Code
package TestProject;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
//import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.MarionetteDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.Select;
import org.openqa.selenium.support.ui.Wait;
import org.openqa.selenium.support.ui.WebDriverWait;
public class TestFirefox {
public static void main(String[] args) throws InterruptedException {
WebDriver driver;
//driver = new FirefoxDriver();
System.setProperty("webdriver.chrome.driver",
"C://Selenium Jars//Chrome//chromedriver_2.31//chromedriver.exe ");
driver = new ChromeDriver();
driver.get("http://www.spicejet.com/?utm_source=Brand%20Campaign%20_&utm_medium=cpc_google&utm_term=O%26D&utm_campaign=Spicejet%20all%20route%20campaign&gclid=CjwKCAiAtorUBRBnEiwAfcp_Y7LCureobkUcdJZY7dqfgx0nlxyYPQeMp6w4MKkaxBEF8QzpovceDBoCXKMQAvD_BwE");
driver.findElement(By.xpath("//*[#id=\'buttons\']/div/div/ul/li[4]/a/span[2]")).click();
Thread.sleep(3000);
WebDriverWait wait =new WebDriverWait (driver, 15);
WebElement test = wait.until(ExpectedConditions.elementToBeClickable(By.id("FlifoSearchInputCompactFlightStatus_originStation")));
//WebElement test=driver.findElement(By.id("FlifoSearchInputCompactFlightStatus_originStation"));
test.click();
//test.sendKeys("GOA(GOI)");
Select s1=new Select(test);
s1.selectByVisibleText("Agartala (IXA)");
}
}
================
error
Starting ChromeDriver 2.31.488763 (092de99f48a300323ecf8c2a4e2e7cab51de5ba8) on port 45746
Only local connections are allowed.
Exception in thread "main" org.openqa.selenium.TimeoutException: Timed out after 15 seconds waiting for element to be clickable: By.id: FlifoSearchInputCompactFlightStatus_originStation
Build info: version: '2.53.0', revision: '35ae25b', time: '2016-03-15 17:00:58'
System info: host: 'NPF0JVX9B', ip: '10.254.101.104', 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.31.488763 (092de99f48a300323ecf8c2a4e2e7cab51de5ba8), userDataDir=C:\Users\DAHIBH~1\AppData\Local\Temp\scoped_dir11036_19151}, takesHeapSnapshot=true, pageLoadStrategy=normal, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=63.0.3239.84, platform=XP, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true, setWindowRect=true, unexpectedAlertBehaviour=}]
Session ID: fcc55c734bff34b0f8d58fec53bd9c02
at org.openqa.selenium.support.ui.WebDriverWait.timeoutException(WebDriverWait.java:80)
at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:261)
at TestProject.TestFirefox.main(TestFirefox.java:27)
Caused by: org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"id","selector":"FlifoSearchInputCompactFlightStatus_originStation"}
(Session info: chrome=63.0.3239.84)
(Driver info: chromedriver=2.31.488763 (092de99f48a300323ecf8c2a4e2e7cab51de5ba8),platform=Windows NT 10.0.14393 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 286 milliseconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.53.0', revision: '35ae25b', time: '2016-03-15 17:00:58'
System info: host: 'NPF0JVX9B', ip: '10.254.101.104', 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.31.488763 (092de99f48a300323ecf8c2a4e2e7cab51de5ba8), userDataDir=C:\Users\DAHIBH~1\AppData\Local\Temp\scoped_dir11036_19151}, takesHeapSnapshot=true, pageLoadStrategy=normal, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=63.0.3239.84, platform=XP, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true, setWindowRect=true, unexpectedAlertBehaviour=}]
Session ID: fcc55c734bff34b0f8d58fec53bd9c02
*** Element info: {Using=id, value=FlifoSearchInputCompactFlightStatus_originStation}
at sun.reflect.GeneratedConstructorAccessor9.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.findElementById(RemoteWebDriver.java:413)
at org.openqa.selenium.By$ById.findElement(By.java:218)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:355)
at org.openqa.selenium.support.ui.ExpectedConditions.findElement(ExpectedConditions.java:899)
at org.openqa.selenium.support.ui.ExpectedConditions.access$0(ExpectedConditions.java:897)
at org.openqa.selenium.support.ui.ExpectedConditions$7.apply(ExpectedConditions.java:205)
at org.openqa.selenium.support.ui.ExpectedConditions$7.apply(ExpectedConditions.java:1)
at org.openqa.selenium.support.ui.ExpectedConditions$22.apply(ExpectedConditions.java:653)
at org.openqa.selenium.support.ui.ExpectedConditions$22.apply(ExpectedConditions.java:1)
at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:238)
... 1 more
Click on flight status -> opens in iframe..so you have to switchTo iframe first before locating further webelements. Modify your code like this, see I've added a line before wait...
driver.switchTo().frame(1); //this line switchto flight-status iframe
The following code worked for me:
driver.get("http://www.spicejet.com/");
driver.findElement(By.cssSelector("a[title='Flights']>span:nth-child(2)")).click();
WebDriverWait wait = new WebDriverWait(driver, 15);
WebElement dropdown = wait.until(ExpectedConditions.elementToBeClickable(By.id("ctl00_mainContent_ddl_originStation1_CTXT")));
dropdown.sendKeys("Goa (GOI)");
Some notes on identifying elements:
Start locating the elements with the HTML code the element itself instead of starting from parent HTML. This will reduce a lot of noise in locator. There are various ways of identifying element: id, name, linkText, css locator, xpath.
Prefer CSS locator over Xpath.
Avoid absolute xpaths, always use relative xpaths. and try to minimize the relativity i.e., as said in first point, start with the element HTML itself.
For selecting from a dropdown you don't have to click on it. Removetest.click();. And try the following , it should work.
WebElement element = driver.findElement(By.id("FlifoSearchInputCompactFlightStatus_originStation")));
Select departureCity = new Select(element);
departureCity.selectByVisibleText("Goa (GOI)");
or you can use
departureCity.selectByValue("GOI");
If exception thrown, please try putting a Thread.sleep(2000) before the WebElement declaration or use the wait methods.

Selenium WebDriver: Unable to Select Element

<input type="text" id="mobile" name="mobile" placeholder="Mobile Number" maxlength="10" value="" onkeyup="javascript:dispLocMob(this);" onkeydown="javascript:dispLocMob(this);" onchange="javascript:dispLocMob(this);">
Shown above is the element that I'm trying to send keys. I tried by xpath and id and all sorts of selectors, but it throws an error that is shown below:
Unable to locate element: {"method":"xpath","selector":"/html/body/div[3]/div/form/div[2]/div[1]/input"}
Command duration or timeout: 338 milliseconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.53.0', revision: '35ae25b', time: '2016-03-15 16:57:40'
System info: host: 'ClaimsCM8', ip: '192.168.110.118', os.name: 'Windows 8', os.arch: 'x86', os.version: '6.2', java.version: '1.7.0_51'
*** Element info: {Using=xpath, value=/html/body/div[3]/div/form/div[2]/div[1]/input}
Session ID: ec543fff-7116-4880-8c98-7c60a1c697d0
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=45.0.2}]
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.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 Selenium.Test2.main(Test2.java:62)
Caused by: org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"xpath","selector":"/html/body/div[3]/div/form/div[2]/div[1]/input"}
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.53.0', revision: '35ae25b', time: '2016-03-15 16:57:40'
System info: host: 'ClaimsCM8', ip: '192.168.110.118', os.name: 'Windows 8', os.arch: 'x86', os.version: '6.2', java.version: '1.7.0_51'
Driver info: driver.version: unknown
at <anonymous class>.FirefoxDriver.prototype.findElementInternal_(file:///C:/Users/EFERNA~1/AppData/Local/Temp/anonymous4369679942726534324webdriver-profile/extensions/fxdriver#googlecode.com/components/driver-component.js:10770)
at <anonymous class>.FirefoxDriver.prototype.findElement(file:///C:/Users/EFERNA~1/AppData/Local/Temp/anonymous4369679942726534324webdriver-profile/extensions/fxdriver#googlecode.com/components/driver-component.js:10779)
at <anonymous class>.DelayedCommand.prototype.executeInternal_/h(file:///C:/Users/EFERNA~1/AppData/Local/Temp/anonymous4369679942726534324webdriver-profile/extensions/fxdriver#googlecode.com/components/command-processor.js:12661)
at <anonymous class>.DelayedCommand.prototype.executeInternal_(file:///C:/Users/EFERNA~1/AppData/Local/Temp/anonymous4369679942726534324webdriver-profile/extensions/fxdriver#googlecode.com/components/command-processor.js:12666)
at <anonymous class>.DelayedCommand.prototype.execute/<(file:///C:/Users/EFERNA~1/AppData/Local/Temp/anonymous4369679942726534324webdriver-profile/extensions/fxdriver#googlecode.com/components/command-processor.js:12608)
Is there something defined in the Web Element that does not let me access the element in my Selenium script?
Any suggestions/advice will be highly appreciated.
Thanks you!
Try as below :-
WebDriverWait wait = new WebDriverWait(driver, 10);
el = wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("mobile")));
el.sendKeys("your value");
Note :- Be ensure before finding element that it is not inside any frame or iframe. If it is inside any frame or iframe you need to switch that frame first as :- driver.switchTo().frame("frame name or id")
Hope it will help you...:)
First of all, If you are using xpaths then use relative xpath instead of absolute as slight change in DOM makes absolute xpaths invalid or refer to a wrong element.
Second try using .click(); before .sendkeys();. So your code can be something like
WebElement ele = dvr.findElement(By.id("mobile"));
ele.click();
ele.sendKeys("your string");
Lastly, make sure you do not have any duplicate elements on the page with same property, i.e. id=="mobile". Hope this helps
Please try below code:
If the element is not in any frame:
driver.findElement(By.id("mobile")).sendKeys("");
If the element is inside a frame:
// Switching to the frame
driver.switchTo().frame(<framename>);
driver.findElement(By.id("mobile")).sendKeys("");
driver.switchTo().defaultContent();
Also, please add some wait after launching the page and entering the text. And even if the code is not working, please check whether the element is visible or not using below code:
if(driver.findElement(By.id("mobile")).isDisplayed()) {
// Add the code given above
}
Hope this helps

Element is not clickable - Error Getting while running Selenium testcases

I am getting following error while running selenium testcases.
Using the versions firefox 45 and selenium-server-standalone 2.52.
org.openqa.selenium.WebDriverException: Element is not clickable at
point (62, 13.333328247070312). Other element would receive the click:
(WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 21 milliseconds Build info: version:
'2.52.0', revision: '4c2593c', time: '2016-02-11 19:06:42' System
info: host:
'mesos-wl-servicetest-8f2fe7b6-d8bd-429f-abfc-cf5d29242b38', ip:
'172.31.6.249', os.name: 'Linux', os.arch: 'amd64', os.version:
'4.4.2-1.el7.elrepo.x86_64', java.version: '1.8.0_51' Driver info:
org.openqa.selenium.firefox.FirefoxDriver Capabilities
[{applicationCacheEnabled=true, rotatable=false,
pageLoadStrategy=fast, handlesAlerts=true, databaseEnabled=true,
version=45.1.0, platform=LINUX, nativeEvents=false,
acceptSslCerts=false, webStorageEnabled=true,
locationContextEnabled=true, browserName=firefox,
takesScreenshot=true, javascriptEnabled=true,
pageLoadingStrategy=fast, cssSelectorsEnabled=true}] Session ID:
d6ae5f7f-be19-4b79-b248-dfb034d6ce1c 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:422)
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.RemoteExecuteMethod.execute(RemoteExecuteMethod.java:35)
at org.openqa.selenium.remote.RemoteMouse.click(RemoteMouse.java:59)
at
org.openqa.selenium.interactions.ClickAction.perform(ClickAction.java:37)
at
org.openqa.selenium.interactions.CompositeAction.perform(CompositeAction.java:50)
at org.openqa.selenium.interactions.Actions.perform(Actions.java:373)
You should try using JavascriptExecutor
WebElement el = driver.findElement....;
JavascriptExecutor executor = (JavascriptExecutor)driver
executor.executeScript("arguments[0].click()", el);
Hope it will help you to perform click...:)
JavascriptExecutor click is an good option to avoid element is not clickable at point (xx,yy). Other element would receive the click.
ANother alternate that you can use is explicit wait for presence of that element
Possible solutions can be ..
1)Try to maximize the browser when you are working with resolutions greater than 1024x768.
driver.manage().window().maximize();
2) Using Actions Class
WebElement element = driver.findElement(By("element"));
Actions action = new Actions(driver);
action.moveToElement(element).click().perform();
3) using JavaScriptExecutor
WebElement el = driver.findElement(By("element"));
JavascriptExecutor executor = (JavascriptExecutor)driver
executor.executeScript("arguments[0].click()", el);

Why I am not able to handle the password field using selenium web driver in new gmail login page?

I am new to selenium web driver, I am writing script to login in to the gmail below is the test script that I created.
public class gmailEmail {
public void login() {
ChromeDriver driver=new ChromeDriver();
driver.get("https://www.gmail.com");
driver.findElementById("Email").sendKeys("XXXXX#gmail.com");
driver.findElementByName("signIn").click();
driver.findElementById("Passwd").sendKeys("XXXX");
//driver.findElementByXPath("//*[#id='Passwd']").sendKeys("XXXXX");
driver.findElementByXPath("//*[#id='signIn']").click();
}
When I run this the error is triggering at "driver.findElementById("Passwd")" following error message is displaying
Exception in thread "main" org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"id","selector":"Passwd"}
(Session info: chrome=49.0.2623.112)
(Driver info: chromedriver=2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4),platform=Mac OS X 10.10.5 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 40 milliseconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.52.0', revision: '4c2593c', time: '2016-02-11 19:03:33'
System info: host: 'Rameshs-MacBook-Pro.local', ip: '192.168.0.105', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.10.5', java.version: '1.8.0_65'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, chrome={chromedriverVersion=2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4), userDataDir=/var/folders/vx/07vnt7mn2jx4fpm983_tq6gm0000gn/T/.org.chromium.Chromium.S1jNgs}, takesHeapSnapshot=true, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=49.0.2623.112, platform=MAC, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]
Session ID: f5790b0589eb054c4e11283c80b82f0e
*** Element info: {Using=id, value=Passwd}
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:422)
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.findElementById(RemoteWebDriver.java:413)
at MobilousLogin.gmailEmail.login(gmailEmail.java:15)
at MobilousLogin.Registration.main(Registration.java:10)
If I debug by inserting a breakpoint at "driver.findElementById("Passwd")" then the whole script is working fine.
Can some one please help me out in understanding what I am doing wrong here?
The error says it isn't able to identify the element that means by the time selenium has executed the command to enter password, the element wasn't loaded or not visible in the UI.
You may want to use ImplicitWait or ExplicitWaits. You can read about them here
You can try ExplicitWait to wait for the Passwd element:
public void login() {
ChromeDriver driver=new ChromeDriver();
driver.get("https://www.gmail.com");
driver.findElementById("Email").sendKeys("XXXXX#gmail.com");
driver.findElementByName("signIn").click();
WebDriverWait wait = new WebDriverWait(driver, 30);
wait.until(ExpectedConditions.presenceOfElementLocated(By.id("Passwd")).sendKeys(""What ever");
driver.findElementByXPath("//*[#id='signIn']").click();
}
try with below code:
public void login() {
ChromeDriver driver=new ChromeDriver();
driver.get("https://www.gmail.com");
driver.findElementById("Email").sendKeys("XXXXX#gmail.com");
driver.findElementByXPath("//*[#id='signIn']").click();
driver.findElementById("Passwd").sendKeys("XXXX");
driver.findElementByXPath("//*[#id='signIn']").click();
}
Add chrome driver capabilities
Try it once.
WebDriver driver = new ChromeDriver();
driver.get("https://www.gmail.com");
driver.manage().timeouts().impliciltyWait(30,TimeUnit.SECONDS);
driver.findElement(By.id("email-display").sendKeys("XXXXX#gmail.com");
driver.findElement(By.id("next"").click();
driver.findElement(By.id("Passwd")).sendKeys("xxxxxx");
driver.findElementByXPath("//*[#id='signIn']").click();

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?