0

I am trying to enter the number 1 into the MasterPack boxes within this table but get an error telling me it is not interactable. enter image description here

My code looked like this and produced the element not interactable error

driver.find_element_by_xpath('//*[@id="asnPick_order_0_itemInfo_TABLE"]/div[1]/div/div/div/table/tbody/tr[1]/td[8]')
.send_keys("1")

The HTML for the table is here, I am trying to edit the MasterPack cell, so the line in between 125 and 1. The cell in the table I am trying to edit has no attributes and is blank. The text for the other cells is not listed under an attribute it is just there inbetween the tags.

<tr><td class="">0001</td>
<td class="">1022-0221-00</td>
<td class="">1004850854</td>
<td class="">8809490582667</td>
<td class="">19</td>
<td class="htAutocomplete">Each<div class="htAutocompleteArrow">&nbsp;</div></td>
<td class="">125</td>
<td class=""></td>
<td class="">1</td>
<td class="htAutocomplete">Each<div class="htAutocompleteArrow">&nbsp;</div></td>
<td class="">D480 3-STAGE TRUE HEPA AIR PURIFIER</td>
<td class=""><a class="no-border" title="Delete"><i class="fa fa-trash-alt fa-lg" aria-hidden="true">&nbsp;</i><div class="screen-reader-only">Delete</div></a></td></tr>

I found that I can successfully click on the box using

driver.find_element_by_xpath('//*[@id="asnPick_order_0_itemInfo_TABLE"]/div[1]/div/div/div/table/tbody/tr[1]/td[8]').click()

I believe this is a dynamic table because When I click on any cell it changes the HTML to show the class = "current highlight" I have a line of code that successfully clicks on the master pack cell. The element not intractable error occurs when I try to send keys I need to figure out how to edit the numbers without a tag, for example here is the html of another cell that already had text in it.

<td class="">8809490582667</td>

I need to edit those numbers, but in the master pack cell where its blank without getting a element not interactable error.

Here is the html from after I click the master pack box, I don't think clicking it is necessary to enter text but then again, I don't know.

<tr><td class="">0001</td>
<td class="">1022-0221-00</td>
<td class="">1004850854</td>
<td class="">8809490582667</td>
<td class="">19</td>
<td class="htAutocomplete">Each<div class="htAutocompleteArrow">&nbsp;</div></td>
<td class="">125</td>
<td class="current highlight"></td>
<td class="">1</td>
<td class="htAutocomplete">Each<div class="htAutocompleteArrow">&nbsp;</div></td><td class="">D480 3-STAGE TRUE HEPA AIR PURIFIER</td><td class=""><a class="no-border" title="Delete"><i class="fa fa-trash-alt fa-lg" aria-hidden="true">&nbsp;</i><div class="screen-reader-only">Delete</div></a></td></tr>

Any ideas on how to use execute script, setAttribute, or send keys to enter numbers into these td Master Pack boxes?

UPDATE: I was able to temporarily enter numbers into the box using this code

driver.find_element_by_xpath(
        '//*[@id="asnPick_order_0_itemInfo_TABLE"]/div[1]/div/div/div/table/tbody/tr[1]/td[8]').click()
element = WebDriverWait(driver, 10).until(
        EC.element_to_be_clickable((By.XPATH, "//table[@class='htCore']//tbody/tr//td[contains(@class, 'highlight')]")))
driver.execute_script('arguments[0].innerHTML = "1"', element)

When this code runs, it correctly places the number one into the box. However, that number one disappears after I click the next button to save the page. I seems like I am only changing the appearance of this form not actually editing the box because it disappears. Why would editing the innerHTML only be temporary? Any ideas on how to keep the 1 from disappearing or permanently edit/send the key to the html? Thanks

Here is the html for after the number 1 is added.

<td class="current highlight">1</td>
Ryan Bobber
  • 97
  • 1
  • 1
  • 6

1 Answers1

0

To set the value as 1 within the column MasterPack for the first row you can use the following based Locator Strategy:

  • Using setAttribute():

    element = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "//table[@class='htCore']//tbody/tr//td[contains(@class, 'highlight')]")))
    driver.execute_script("arguments[0].setAttribute('value','1')", element)
    
  • Using setValue():

    element = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "//table[@class='htCore']//tbody/tr//td[contains(@class, 'highlight')]")))
    driver.execute_script("arguments[0].value='1';", element)
    

Reference

You can find a couple of relevant discussions in:

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • This did not work No error was produced but it did not update the box. A new value tag was created in the HTML but no text appeared in the cell I will send a pic of the html – Ryan Bobber Jul 16 '20 at 14:56
  • Checkout the updated answer and let me know the status. – undetected Selenium Jul 16 '20 at 14:59
  • That did not work either. Same thing as the first answer. No error but no text was created in the box. A new value tag was created again – Ryan Bobber Jul 16 '20 at 18:45
  • Is there a way to do a general send_keys command with execute script? – Ryan Bobber Jul 16 '20 at 18:49
  • Also I don't understand why I get a noninteractable error when I try to send keys but the program can successfully click the masterpack cell. – Ryan Bobber Jul 16 '20 at 19:44
  • @RyanBobber In those cases you have update the question with the relevant HTML before and after click. That may help us debug the issue. – undetected Selenium Jul 16 '20 at 20:42
  • I have reworked the question to include what I have found out so far, what I have tried and some updated HTML. Let me know if you have any idea. Thank you for your help – Ryan Bobber Jul 16 '20 at 21:03
  • I made a little bit of progress today. I added an update portion to the question. Sorry to keep bugging you but if you have any ideas I would greatly appreciate it. Thank you – Ryan Bobber Jul 17 '20 at 16:37
  • The change in `master pack cell` due to the click is crucial. Unless you explain that as it is, it's gonna be tough to assume whats happening there. – undetected Selenium Jul 17 '20 at 16:40