简体   繁体   English

使用 JSExecutor 从另一个文档中获取文档

[英]Get DOCUMENT from another DOCUMENT with JSExecutor

I am trying to get an element from a page and click on it.我正在尝试从页面中获取一个元素并单击它。 But I came across the #document tag.但我遇到了#document 标签。 My last step with this problem:我解决这个问题的最后一步:

var doc = (OpenQA.Selenium.Remote.RemoteWebElement)_driver.ExecuteQuery("return window.document");
doc.FindElementByXPath("//span[text()='Принять']").Click();

But answer is:但答案是:

 OpenQA.Selenium.NoSuchElementException: "no such element: Unable to locate element:

{"method":"xpath","selector":"//span[text()='Принять']"} (Session info: chrome=80.0.3987.132)" {"method":"xpath","selector":"//span[text()='Принять']"} (会话信息: chrome=80.0.3987.132)"

If i try to do it in browser - all is ok.如果我尝试在浏览器中执行此操作 - 一切正常。 Only one match.只有一场比赛。

Please help with it请帮忙

Find the way.找到方法。 Thanks to @itronic1990 .感谢@itronic1990。

    Driver.SwitchTo().Frame(0);
    var doc = (OpenQA.Selenium.Remote.RemoteWebElement)_driver.ExecuteQuery(
        "return document");
    doc.FindElementByXPath("//button[./span[text()='Принять']]").Click();

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

相关问题 如何从另一个文档angularId的Id获取文档 - How to get a document from Id gotten from another document angularFirestore 根据MongoDB中一个文档的另一文档的属性获取结果 - Get result based on property of another document from one document in MongoDB Selenium JSExecutor - 从 Amcharts 条形气泡中获取价值 - Selenium JSExecutor - Get value from Amcharts bar bubble 从另一个 #document JavaScript !Doctype 获取价值 - Get value from another #document JavaScript !Doctype 从另一个文档引用 firebase 文档变量 - Referencing firebase document variables from another document mongoose 从另一个文档向一个文档添加一个字段 - mongoose add a field to a document from another document 如何从另一个HTML文档中获取HTML元素并显示在当前文档中? - How To Get an HTML element from another HTML document and display in current document? Firestore 从一个文档中获取值并更新另一个文档上的现有值 - Firestore get value from one document and update an existing value on another document Rethinkdb,从1个文档中获取值,然后在另一个文档上插入value + 1 - Rethinkdb, Get value from 1 document then insert the value+1 on another jQuery获取iframe文档并设置另一个iframe - Jquery get iframe document and set another iframe
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM