in order to automize some tasks in the browser with Selenium I need to identify a certain field on a website and click it. Because the values I'm using to identify the correct field can be displayed multiple times I'm iterating through the findings including multiple conditions. Maybe the code is written ineffectivly, but the conditions - with the goal of locating the correct x and y coordinate is working. I'd like to know if I can somehow modify a location['x'] value in order the execute a click command.
# finding the X Value
tempmatchesx = driver.find_elements_by_xpath("//*[text()='" + tempoa + "']")
tempmatchesxVal =''
if indicator == '1':
for i in tempmatchesx:
if (i.location['x'] >= temptype['x']) and (i.location['y'] >= temptype['y']) and (i.location['x'] < temptypeoppo['x']):
tempmatchesxVal = i.location['x']
break
elif indicator == '2':
for i in tempmatchesx:
if (i.location['x'] >= temptype['x']) and (i.location['y'] >= temptype['y']) and (i.location['x'] > temptypeoppo['x']):
tempmatchesxVal = i.location['x']
break
# finding the Y Value
tempmatchesy = driver.find_elements_by_xpath("//*[text()='" + tempgoals + "']")
tempmatchesyVal =''
if indicator == '1':
for i in tempmatchesy:
if (i.location['x'] >= temptype['x']) and (i.location['y'] >= temptype['y']) and (i.location['x'] < temptypeoppo['x']):
i.location['x'] = tempmatchesxVal
i.click()
break
elif indicator == '2':
for i in tempmatchesy:
if (i.location['x'] >= temptype['x']) and (i.location['y'] >= temptype['y']) and (i.location['x'] > temptypeoppo['x']):
i.location['x'] = tempmatchesxVal
i.click()
So basically the part my question is referring to is the following:
i.location['x'] = tempmatchesxVal
i.click()
Within an iteration, is it somehow possible to replace the location-X value with the before identified x value (tempmatchesxVal)? Or could the way I did it work and the failure (without error code) might be somewhere else? For now, no item gets clicked.