I wanted to concatenate the i of the for loop with xpath but it gives me this error “TypeError: can only concatenate str (not “int”) to str”. How could I fix this problem?
guardaremail = 'asd@asd' teste = self.driver.find_element_by_xpath("//*[text()='" + guardaremail + "']") tabela = self.driver.find_elements_by_xpath("/html/body/div[1]/div/table/tbody/tr") for i in range(1, len(tabela), 1): #verifica if tr = email emailteste = self.driver.find_element_by_xpath("/html/body/div[1]/div/table/tbody/tr[" + i + "]/td[2]") botaoteste = self.driver.find_element_by_xpath("/html/body/div[1]/div/table/tbody/tr[" + i + "]/button[1]") #carrega no tr com id = "ui positive button" if emailteste == teste: botaoteste.click()
Advertisement
Answer
use "tr"+str(i)+"/td