今天我的网站测试出现了一个奇怪的错误:
ElementNotVisibleException: Message: Element is not currently visible and so may not be interacted with
我想用selenium测试一些非常简单的东西,只是为了测试当我点击我的logo时,我是否被重定向到良好的登录页。 我做了一个非常简单的代码:
@classmethod
def setUp(self):
self.driver = webdriver.Firefox()
self.driver.get('http://localhost')
def test_navigation_to_home_page(self):
# Click on the logo and check landing page
self.driver.find_element_by_xpath("/html/body/header/div[2]/div/div/div//a").click()
self.assertEqual(self.driver.current_url, 'http://localhost/')
@classmethod
def tearDown(self):
self.driver.quit()
当我执行这个代码时,我有上面的错误。我试着用一个简单的时间。睡眠,只是看看是否有帮助,但没有任何改变。 您可能会在xpath表达式中看到“//a”。这不是一个错误,因为如果我写/figure/a,我有一个NoSuchElementException。 我要单击的包含徽标的代码如下:
你知道吗页面布局.html.twig地址:
{% block header %}
{{ render(controller('MyBundle:PageLayout:getHeader', {'active_page':activePage})) }}
{% endblock %}
你知道吗标题.html.twig地址:
<header id="header" class="header navbar-fixed-top">
{% include 'MyBundle:PageLayout:cookie_barre.html.twig'%}
{% include 'MyBundle:PageLayout:metabarre.html.twig'%}
<div class="header-bar container-fluid">
<div class="row">
<div class="container">
<div class="row">
<figure class="header-logo header-item col-xs-8 col-sm-3"><a href="page-home">{{ ez_render_field(header, 'fs_header_logo', {'parameters':{'class': 'img-responsive'} } ) }}</a></figure>
{{ render(controller('MyBundle:PageLayout:getMainMenu', {'active_page':activePage, 'header':header})) }}
</div>
</div>
</div>
</div>
我在另一个应用程序上做了很多Selenium测试,没有出现这种错误。是因为我用ez平台渲染我的照片吗?有办法解决这个问题吗?所有的网站工作正常,只是需要自动化一些测试。你知道吗
谢谢你。你知道吗
目前没有回答
相关问题 更多 >
编程相关推荐