I try to put in new values in the rows of the table on this website using selenium. My approach so far:
URL = "https://sigmazone.com/catapult-grid/"
browser = webdriver.Firefox("/usr/lib/firefox")
browser.get(URL)
# enter number of rows = 1
num_rows = browser.find_element_by_id("noOfRows")
num_rows.clear()
num_rows.send_keys("1")
# updating number of rows
update_btn = browser.find_element_by_id("updateNoOfRows")
update_btn.click()
cells = browser.find_elements_by_class_name("htRight")
# skipping the first entry in cells because it contains a div with the whole table
for cell in cells[1:]:
cell.click()
cell.send_keys("150")
Trying this gave me Message: Element <td class="htRight current highlight"> is not reachable by keyboard from the send_keys(150) method.
UPDATE:
This is how I solved it. Resetting the action chain is essential. Otherwise all previous actions are performed every time you do action.perform()
def set_val(selected_cell, value):
action.move_to_element(selected_cell).double_click() # select the cell
action.send_keys(Keys.BACKSPACE, Keys.BACKSPACE, Keys.BACKSPACE) # deleting previous numbers
action.send_keys(str(value)) # send the value
action.perform() # perform the action chain
action.reset_actions() # this alone did not reset the action chain completely
for device in action.w3c_actions.devices:
device.clear_actions()