I am currently trying to send information to an input field in Chrome. I am working with variables when using the driver.find_element function.
What I have tried:
ProjectID = '"' + str('driver.find_element(By.XPATH, "//input[@ID=' + "'" + '_obj__TIMESHEETITEMS_' + str(rowCounter) + '_-_obj__PROJECTID' + "']" + '").send_keys(' + "'" + str(nonProjects['Projects'][rowCounter-2]) + "'" + ')') + '"'
After the variables are applied, it looks like this when applying print(ProjectID):
"driver.find_element(By.XPATH, "//input[@ID='_obj__TIMESHEETITEMS_2_-_obj__PROJECTID']").send_keys('OMSH001')"
I also tried without the quotation marks in the front:
ProjectID = str('driver.find_element(By.XPATH, "//input[@ID=' + "'" + '_obj__TIMESHEETITEMS_' + str(rowCounter) + '_-_obj__PROJECTID' + "']" + '").send_keys(' + "'" + str(nonProjects['Projects'][rowCounter-2]) + "'" + ')')
Which looks like this when applying print(ProjectID):
driver.find_element(By.XPATH, "//input[@ID='_obj__TIMESHEETITEMS_2_-_obj__PROJECTID']").send_keys('OMSH001')
I am calling the variable with:
driver.execute_script(ProjectID)
The error I am getting without the quotation marks is that the driver is not defined. When applying the quotation marks, that error goes away, but then the program does not do anything.
Any help is greatly appreciated, as I have been stuck on this error for days.