【发布时间】:2015-03-26 16:00:26
【问题描述】:
我正在尝试检查当我点击锚链接时,某些部分确实位于浏览器的顶部(我希望我在这里说得通。)
我的测试是这样的:
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)
断言只是为了让我可以看到我的指纹。 我从中得到的是,即使我看到锚点起作用了,位置字典也保持不变。所以我想我没有使用正确的功能。
你能想出另一种方法来检查对锚点的点击是否达到了预期的效果? (要么不查看位置,要么以正确的方式查看位置)
【问题讨论】:
-
点击
anchor后,您有什么期待? -
@Saifur 页面滚动到特定部分 (
<section id="123123"></section>)
标签: python testing selenium selenium-webdriver anchor