I am trying to find set of elements then click on each element which takes me to a new page and perform some steps on that new page. Then click on the back button on the browser or a button on the new page that takes me to the previous page then find the same elements and repeat the above process for the rest of the elements.
I am using the below code to find the elements again before proceeding to find the elements but my code isn't working. Can someone please help?
elements = driver.find_elements_by_css_selector("#top-tables-chart-container > div > svg > g > g > rect")
counter = 0
for counter in range(counter, len(elements)):
elements = driver.find_elements_by_css_selector("#top-tables-chart-container > div > svg > g > g > rect")
webdriver.ActionChains(driver).move_to_element(elements[counter]).click().perform()
time.sleep(5)
tableNameLink= elements[counter].find_element_by_xpath("//div[@class='d3-tip bar-chart top-tables-tooltip n']//div[@class='left-section']//div[@class='table-name']//a[contains(@href,'#/table/')]")
print tableNameLink
tableNameLink.click()
tableName = driver.find_element_by_xpath("//div[@class='discover-design-transform-container clearfix']//div[@class='left-header-section clearfix']//div[@class='entity-info table-type']//span[@class='entity-identifier']")
table = tableName.text
print " Table: " + table
print '\n'
if table == "lineitem":
TableAccessFreqChartInfoBadgesValidation(self.driver).test_table_access_freq_chart_info_badges_validation("F","8","13","13")
time.sleep(1)
print '\n'
if table == "orders":
TableAccessFreqChartInfoBadgesValidation(self.driver).test_table_access_freq_chart_info_badges_validation("D","4","9","9")
time.sleep(1)
print '\n'
topUsagePatternsTab = driver.find_element_by_xpath("//div[@id='workload-level-tabs']//a[@href='#/topUsagePatterns']")
topUsagePatternsTab.click()