No such element error

216 views
Skip to first unread message

vaumento....@gmail.com

unread,
Oct 22, 2016, 9:23:25 AM10/22/16
to Selenium Users
Hi I'm using cucumber and selenium version 3 with java, I'm trying to fill-up a sign-up sheet in a test website but I keep getting:

org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"id","selector":"name"}
  (Session info: chrome=54.0.2840.71)
  (Driver info: chromedriver=2.24.417431 (9aea000394714d2fbb20850021f6204f2256b9cf),platform=Windows NT 6.1.7601 SP1 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 31 milliseconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: 'unknown', revision: '31c43c8', time: '2016-08-02 21:57:56 -0700'
System info: host: 'FWSPH-PC-1071', ip: '192.168.0.121', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', 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.24.417431 (9aea000394714d2fbb20850021f6204f2256b9cf), userDataDir=C:\Users\vaumento\AppData\Local\Temp\scoped_dir236_18522}, takesHeapSnapshot=true, pageLoadStrategy=normal, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=54.0.2840.71, platform=XP, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]
Session ID: c2bbb1c3acda1d3fa345a6469c7b73ae
*** Element info: {Using=id, value=name}
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:683)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:377)
at org.openqa.selenium.remote.RemoteWebDriver.findElementById(RemoteWebDriver.java:427)
at org.openqa.selenium.By$ById.findElement(By.java:218)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:369)
at com.practiceselenium.practiceexercises.sampleExercises.i_fill_up_all_the_needed_details(sampleExercises.java:40)
at ?.When I fill in all the needed details(D:/vaneza_workspace/practiceexercises/src/test/java/testcases.feature:9)

not only that but every time I run the test, there are two chrome windows that shows up. One with the test that I am doing and the other one just empty. Can someone help me with this case?

This is my code:

package com.practiceselenium.practiceexercises;

import cucumber.api.java.en.*;
import org.openqa.selenium.SearchContext;
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;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class sampleExercises{
WebDriver driver = new ChromeDriver();
//WebDriver driver = new FirefoxDriver();
@Given("^I navigate to techno\\-geek\\.co\\.uk\\/callmycab$")
public void i_navigate_to_techno_geek_co_uk() throws Throwable{
System.out.println("Going to techno-geek.co.uk/callmycab");
driver.navigate().to("http://techno-geek.co.uk/callmycab/");
driver.manage().window().maximize();
}
@And("^I click the sign\\-up tab")
public void i_click_the_sign_up_tab() throws Throwable{
driver.findElement(By.xpath(".//*[@id='navbar']/ul/li[1]/a/nav/span[2]")).click();
}
@Then("^I successfully arrive on the page$")
public void i_successfully_arrive_on_the_page() throws Throwable {
   System.out.println("Getting page title");
   System.out.println(driver.getTitle());
}
@When("^I fill in all the needed details$")
public void i_fill_up_all_the_needed_details() throws Throwable{
driver.findElement(By.id("name")).sendKeys("Vaneza Mae Aumento");
driver.findElement(By.xpath(".//*[@id='address']")).sendKeys("Davao City");
driver.findElement(By.xpath(".//*[@id='phone']")).sendKeys("09336911693");
driver.findElement(By.xpath(".//*[@id='email']")).sendKeys("vaneza....@flatworld.com.ph");
driver.findElement(By.xpath(".//*[@id='password']")).sendKeys("password");
driver.findElement(By.xpath(".//*[@id='biodata']")).sendKeys("Sample Text");
driver.findElement(By.xpath(".//*[@id='hobby']")).sendKeys("Sample Text");
driver.findElement(By.xpath(".//*[@id='job']")).sendKeys("Quality Assurance");
}
@Then("^I click the signup button$")
public void i_click_the_sign_up_button() throws Throwable{
//not written a code yet
}
@And("^I successfully signup$")
public void i_successfully_sign_up() throws Throwable{
//not written a code yet
}
}

sski...@gmail.com

unread,
Oct 24, 2016, 3:24:55 AM10/24/16
to Selenium Users
The reason could the element is not yet loaded, so try putting some delay using Thread.sleep()  or use explicit wait. 
Reply all
Reply to author
Forward
0 new messages