Im new with selenium/python and that my problem: I have a simple site with a couple of news. I try to write script that iterates over all news, open each one, do something and goes back to all other news All news have same xpath, difference only with last symbol - i try to put this symbol as variable and loop over all news, with increment my variable after every visited news:
x = len(driver.find_elements_by_class_name('cards-news-event'))
print (x)
for i in range(x):
driver.find_element_by_xpath('/html/body/div[1]/div[1]/div/div/div/div[2]/div/div[3]/div/div[1]/div/**a["'+i+'"]**').click()
do something
i = i+1
Python return error: "Except type "str", got "int" instead. Google it couple of hours but really can't deal with it Very appreciate for any help
a["'+str(i)+'"]or'.../a["%s"]' % i? P.S. Do not use absolute XPath expressions'.../a["{}"]'.format(i)with python3 andf'.../a["{i}"]'starting with python3.6.