简体   繁体   English

#document 是什么意思?

[英]What does #document mean?

This is the HTML file I have.这是我拥有的 HTML 文件。 I am trying to use Selenium-Webdriver API along with ChromeDriver to send_keys to an input filed inside the <body> .我正在尝试将Selenium-Webdriver APIChromeDriver一起使用以将send_keys发送到<body>内的input字段。 But I can't access anything which is inside of #document .但我无法访问#document内部的任何内容。 I cannot figure out why.我不知道为什么。 Can someone please tell me what this #document means and how can I access any of the elements inside this using Selenium .有人可以告诉我这个#document是什么意思,我如何使用Selenium访问其中的任何元素。

<html>
<head>…<head>
<frameset >
    <frame>...</frame>
            <frame name="mainFrame" src>
                #document
                    <html>
                      <head>…</head>
                      <body>…</body>
                    </html>
        </frame>
    </frameset>
</frameset>

This is a router webpage, the actual webpage is HUGE, so I haven't pasted it here.这是一个路由器网页,实际网页很大,所以我没有在这里粘贴。

路由器网页

Just to summarize on what I learnt and implemented. 只是总结我学到和实施的内容。

  1. document is a virtual element, which doesn't really mean anything. document是一个虚拟元素,并不代表任何东西。

  2. If you have mulitple frames/framesets, you will have to switch frames. 如果你有多个帧/帧集,你将不得不切换帧。

    a. 一个。 so first get to the default content. 所以首先获取默认内容。 driver.switch_to_default_content()

    b. then get to the frame that you want to work with. 然后到达你想要使用的框架。 frame = driver.find_element_by_name('mainFrame')

  3. Then play with the elements in that frame. 然后玩那个框架中的元素。

I have tried to do the same process in C#, and this worked for me.我曾尝试在 C# 中执行相同的过程,这对我有用。 (I leave the code here for someone who maybe is looking at this in C#). (我将代码留给可能正在 C# 中查看此代码的人)。 I hope this will be useful for someone!我希望这对某人有用!

var FrameName = driver.FindElement(By.Name("...Frame Name..."));    
driver.SwitchTo().Frame(FrameName);    
var elem = driver.FindElement(By.XPath("... Xpath from in of the 
        Frame..."));    
elem.Click();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM