问题
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