Reputation: 1184
I am having serious difficulty filling in text boxes on this website. The element is type="text". It keeps returning as AttributeError: 'NoneType'.
I used a try clause to see if it was actually being clicked on, and it is not erring out. In addition, the textbox is selected and when I leave it as my front window, I can type in the text box without clicking anything after the error occurs.
I tried extending the pause before the click by 1 minute to no effect.
I tried selecting by xpath, same results.
I tried clicking the object, pausing 10 seconds, and clicking the object again. Nothing.
my code:
def Search(driver,productID):
print "Initiate Search"
#Fill in current product ID
#/html/body/table[3]/tbody/tr/td/table/tbody/tr/td[2]/div[2]/form/table/tbody/tr/td/input
try: inputElement = driver.find_element_by_name("CategoryName").click()
except: print "could not click"
print "Clicked Product ID"
time.sleep(5)
inputElement.send_keys(str(productID)) ##Line 105 - Errors out here
Error
Traceback (most recent call last):
File "/Users/ME/Documents/PYTHON/Creating Static Attributes/StaticWAttributes_1.py", line 246, in <module>
Search(driver,productID)
File "/Users/ME/Documents/PYTHON/Creating Static Attributes/StaticWAttributes_1.py", line 105, in Search
inputElement.send_keys(str(productID))
AttributeError: 'NoneType' object has no attribute 'send_keys'
Last Output Print Statement:
Initiate Search
Clicked Product ID
HTML:
<table cellSpacing="0" cellPadding="0" border="0">
<tr>
<td class="actionrow">Search Products by
<select name="categorytype">
<option selected value="name">Product Name or Description</option>
<option value="catid">Product ID</option>
</select> <input type="text" name="CategoryName" value="" size="20"><? <<-- I AM TRYING TO CLICK THIS ?>
in
<select name="ddlproductType" ID="Select2">
<option selected value="100">All</option>
<option value="1">Versioned</option>
<option value="7">Variable</option>
<option value="5">Static with Attributes</option>
<option value="11">PowerPoint</option>
</select>
<input type="submit" value="Go" name="action" onClick="javascript:resetAll();">
</td>
</tr>
</table>
Upvotes: 1
Views: 11282
Reputation: 9019
Your problem is here:
try: inputElement = driver.find_element_by_name("CategoryName").click()
I'm not sure what inputElement
is in the case of python, but I'm guessing it's still a null. I don't think click()
returns anything.
If you change it to this, it should work:
try: inputElement = driver.find_element_by_name("CategoryName")
inputElement.click()
Upvotes: 9