我的方案:登錄到我的帳戶後,將在網頁上打開插頁式廣告。我使用的情況是,如果顯示間質性我將關閉喜歡我們如何找到蟒蛇中元素的可見性?
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/area [ 1]「} Stacktrace: at FirefoxDriver.prototype.findElementInternal_(file:///var/folders/7f/q00y41s11xdfknssfymz3qfc0000gv/T/tmp8w0k6J/extensions/[email protected]/components/driver-component.js:10770) at fxdriver.Timer.prototype.setTimeout/< .notify(file:///var/folders/7f/q00y41s11xdfknssfymz3qfc0000gv/T/tmp8w0k6J/extensions/[email protected]/components/driver-component.js:625)