Afternoon. You are currently trying to use the Selenium web editor to scroll through the list of links on a page. In particular, he clicks the link, capturing a line of text from the specified page to write to the file, return and click the next link in the list. The following is what I have:
def test_text_saver(self): driver = self.driver textsave = open("textsave.txt","w") list_of_links = driver.find_elements_by_xpath("//*[@id=\"learn-sub\"]/div[4]/div/div/div/div[1]/div[2]/div/div/ul/li") """Initializing Link Count:""" link_count = len(list_of_links) while x <= link_count: print x driver.find_element_by_xpath("//*[@id=\"learn-sub\"]/div[4]/div/div/div/div[1]/div[2]/div/div/ul/li["+str(x)+"]/a").click() text = driver.find_element_by_xpath("//*[@id=\"learn-sub\"]/div[4]/div/div/div/div[1]/div[1]/div[1]/h1").text textsave.write(text+"\n\n") driver.implicitly_wait(5000) driver.back() x += 1 textsave.close()
When launched, it goes to the start page and ... returns to the main page, and not to the subpage that it should have. Seal x, I see that it increases three times, not one. After that, he also falls. I checked all my xpaths, etc., and also confirmed that it gets the correct count of the number of links in the list.
Any input is much appreciated - it really is just bending my python / automation, as I just fall into both. Thanks in advance!
Troch source share