I am new to Python and I am trying to build a program that copies data from Excel to different fields on a webpage platform. The problem is that the XPath values of the fields in this table change on every session and I can't share the platforms' credentials for you to get a better understanding. I know it is a long shot but I hope to maybe find a solution that I understand and I can apply in my case.
so I tried to locate the position of each field and extract its XPath in a variable. Below is the code that I ended with.
c2_element = driver.find_element(By.XPATH, '//*[@class="table table-condensed"]/tbody/tr[2]/td[3]')
print(c2_element)
cell_C2_xpath = driver.execute_script("return arguments[0].getPath()", c2_element[0])
# Load the Excel file
workbook = openpyxl.load_workbook(excel_file_path)
sheet = workbook.active
# Copy cell values to respective fields
cell_C2_value = sheet['C2'].value
cell_C2 = driver.find_element(By.XPATH, cell_C2_xpath)
cell_C2.send_keys(cell_C2_value)
Also if you think that using another programming language would help my need I am open to try anything. I tried using Python because of the selenium library.