我正在使用Python和Selenium一起工作,并且使用以下命令创建了一个Web驱动程序实例driver = webdriver.Firefox()
并正确创建了Web驱动程序实例。find_element_by_id无法找到元素
在此之后,我试图通过ID:str_title = driver.find_element_by_id("banner-section-title")
获取元素。但我收到以下错误:
NoSuchElementException: Message: Unable to locate element: {"method":"id","selector":"banner-section-title"}
Stacktrace:
at FirefoxDriver.prototype.findElementInternal_ (file:///tmp/tmpR0IR8T/extensions/[email protected]/components/driver-component.js:10299)
at FirefoxDriver.prototype.findElement (file:///tmp/tmpR0IR8T/extensions/[email protected]/components/driver-component.js:10308)
at DelayedCommand.prototype.executeInternal_/h (file:///tmp/tmpR0IR8T/extensions/[email protected]/components/command-processor.js:12282)
at DelayedCommand.prototype.executeInternal_ (file:///tmp/tmpR0IR8T/extensions/[email protected]/components/command-processor.js:12287)
at DelayedCommand.prototype.execute/< (file:///tmp/tmpR0IR8T/extensions/[email protected]/components/command-processor.js:12229)
确实有'ID =“的旗帜形部标题元素''存在于页面上? –
是的,它是存在的,当我试图点击链接从我的测试用例使用“点击链接id =横幅部分标题”它工作正常。但是,当我试图从关键字文件,从.py文件做同样的事情,我得到了上述错误 – Madhuri