`#driver.find_element_by_xpath('//div[@id="groups"]/div/div/div/div/div[2]/div[1]/div/div/button').click() i = 5 gPath1 = str("'//div[@id="groups"]/div/div/div/div/div[2]/div[") gPath2 = str(i) gPath3 = str("]/div/div/button'") gPath = gPath1 + gPath2 + gPath3
driver.find_element_by_xpath(gPath).click()`
#driver.find_element_by_xpath('//div[@id="groups"]/div/div/div/div/div[2]/div[1]/div/div/button').click()
i = 5
gPath1 = str("\'//div[@id=\"groups\"]/div/div/div/div/div[2]/div[")
gPath2 = str(i)
gPath3 = str("]/div/div/button\'")
gPath = gPath1 + gPath2 + gPath3
driver.find_element_by_xpath(gPath).click()
I'm getting InvalidSelectorException error while using variable, but when i use the commented line it is working fine. Please help.