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.
Update:
The purpose of the whole is to click an element where I dont know now the content from, therefor I can't simply search for that. There I identifying the column and row where the element is lcoated.
Two "find_elements_by_xpath" are done with different inputs - the first is tempoa to identify column (x-value) and the second tempgoals for the row (y-value).
Apparently I can't modify an i.location[coordinate] - how can I then click that element?