【发布时间】:2016-05-16 17:30:11
【问题描述】:
我的场景:登录我的帐户后,网页上会打开一个插页式广告。我的用例是,如果显示插页式广告,我会像
一样关闭插页式广告inter=driver.find_element_by_xpath("/*x-path location/*")
if inter1.is_displayed():
inter1.click()
但是对于少数用户,插页式广告不会显示,我已经更新了我的代码,如下所示
if(driver.find_element_by_xpath("/*x-path location/*").is_displayed()):
driver.find_element_by_xpath("/*x-path location/*").close()
else:
(kept my rest of the class part here)
但我的脚本失败并出现以下错误
有人能帮我提些建议吗,在此先感谢
selenium.common.exceptions.NoSuchElementException:消息:无法定位元素:{"method":"xpath","selector":"/html/body/div[1]/div[2]/div/map /区域[1]"} 堆栈跟踪: 在 FirefoxDriver.prototype.findElementInternal_ (file:///var/folders/7f/q00y41s11xdfknssfymz3qfc0000gv/T/tmp8w0k6J/extensions/fxdriver@googlecode.com/components/driver-component.js:10770) 在 fxdriver.Timer.prototype.setTimeout/<.notify>
【问题讨论】: