Q: selenium exceptions.NoSuchElementException: The html code snippet as:
<thead id="addDet:cust:th" class="emp">
<tr id="addDet:cust:ch" class="emp">
<th class="emp" scope="col" id="addDet:cust:ch:j_idt484">S. No.</th>
<th class="emp" scope="col" id="addDet:cust:ch:j_idt487">Name 
<font color="#FA5882">*</font></th>

I tried to fill the field as:
driver.find_element_by_id("addDet:cust:j_idt487").send_keys("XX")

But I am getting the error as:
selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: {"method":"id","selector":"psdetail:j_idt490"}

Any help will be appreciable.

A: The xpath you've provided doesn't point to a field to input data into, in fact it's actually pointing to the column header. That's why you weren't able to input data into it.
Please try the below xpath to fill the name and age in the first row in the passenger details:


*

*The below code will fill the name of passenger in first row:
driver.find_element_by_xpath("(//tbody[@id='addPassengerForm:psdetail:tb']//input[contains(@id,'psgnName')])[1]").send_keys("ABC")


*The below code will fill the age of passenger in first row: 
driver.find_element_by_xpath("(//tbody[@id='addPassengerForm:psdetail:tb']//input[contains(@id,'psgnAge')])[1]").send_keys("24")
Similarly for inputting data into the next row for passenger name, you just have to tweak the last part of xpath from [1] to [2].

A: You have a typo in your code.  You forgot the :ch: after :cust:.

A: After fixing your selector (Imcphers answer/comments), is it possible that the element is NOT in the DOM at the time you're trying to find the element?  Is it dynamically loaded?  If so you'll probably have to use an explicit or implicit wait.
http://docs.seleniumhq.org/docs/04_webdriver_advanced.jsp
Try
driver.implicitly_wait(10)
after you initialize your driver

A: try using xpath contains or CSS start with
//xpath
"//*[contains(. , 'S. No.')]"

A: The id attribute value looks very much like it is dynamically generated. In this case it is not a good idea to rely on it. Instead, use the element's text:
driver.find_element_by_xpath("//th[. = 'S. No.']")

