mardi 27 janvier 2015

Selenium - Get location after clicking on an anchor

I'm trying to check the fact that when I click on an anchor link, some section is really at the top of the browser (I hope I'm making sense here.)


My test looks like that:



class Tests(unittest.TestCase):
def setUp(self):
self.driver = webdriver.Chrome(chromedriver)
self.accept_next_alert = True
self.driver.set_window_size(1100, 800)
self.base_url = "http://someurl"

def test_anchor(self):
driver = self.driver
driver.get(self.base_url)
driver.implicitly_wait(1)
location = driver.find_element_by_xpath(
"//section[@id='123123']").location
print location

driver.find_element_by_partial_link_text("anchor_text").click()
location = driver.find_element_by_xpath(
"//section[@id='123123']").location
print location

self.assertTrue(False)


The assertion is just so I can see my prints. What I get from that is that even though I see that the anchor worked, the location dict stays the same. So I guess I'm not using the right feature.


Could you think of another way to check that the click on the anchor had the expected effect? (by either not looking at the location or by looking at the location the right way or else)


Aucun commentaire:

Enregistrer un commentaire