Handling contents of Embed tag in selenium python

五迷三道 提交于 2020-12-15 06:06:46

问题


How can I access embedded part from web page and contents using selenium and python

<embed src="RainPastDailyMonth.php" width="100%" height="100%">

Embedded part has input button elements which I need to access using selenium but getting

Message: no such element: Unable to locate element: 

{"method":"xpath","selector":"/html/body/center/b/input"} 

for below code

driver.find_element(By.XPATH, '/html/body/center/b/input')

where '/html/body/center/b/input' is XPATH for input button


回答1:


This is answer to my question. I am able to access the elements in embed block by switching frame to <embed> element.

driver.switch_to.frame(driver.find_element(By.CSS_SELECTOR, 'body > embed'))

here 'body > embed' is selector for <embed> element.




回答2:


You cannot.

The <embed> element creates an embedded panel in which a third-party application can run. In other words: it is outside of the DOM. Selenium is able to operate only on items in the browser's DOM.

You will need to access this third-party application using some other means. AutoIT or Sikuli are popular options.



来源:https://stackoverflow.com/questions/48957851/handling-contents-of-embed-tag-in-selenium-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!