selenium XPATH匹配</html>;

selenium XPATH匹配</html>;,selenium,xpath,Selenium,Xpath,Selenium中匹配标记的XPATH是什么?我想做一个“等待”对象。它会等待,直到html文件中出现 public class SimpleChrome { private ChromeDriver driver; private void WaitForPageLoad() { var wait = MakeDefaultWait(); wait.Until(x => ((IJavaScriptExecutor)x).ExecuteScript(&q

Selenium中匹配
标记的XPATH是什么?我想做一个“等待”对象。它会等待,直到html文件中出现

public class SimpleChrome {
  private ChromeDriver driver;
  private void WaitForPageLoad()
  {
      var wait = MakeDefaultWait();
      wait.Until(x => ((IJavaScriptExecutor)x).ExecuteScript("return document.readyState").Equals("complete"));
  }
  DefaultWait<IWebDriver> MakeDefaultWait()
  {
      DefaultWait<IWebDriver> fluentWait = new DefaultWait<IWebDriver>(driver);
      fluentWait.Timeout = TimeSpan.FromSeconds(20);
      fluentWait.PollingInterval = TimeSpan.FromMilliseconds(1000);
      fluentWait.IgnoreExceptionTypes(typeof(NoSuchElementException));
      fluentWait.Message = "Element to be searched not found";
      return fluentWait;
  }
  public SimpleChrome()
  {
      ChromeOptions opt = new ChromeOptions();
      opt.AddArgument("--disable-blink-features=AutomationControlled");
      opt.AddExcludedArguments("enable-automation");
      opt.AddAdditionalCapability("useAutomationExtension", false);
      driver = new ChromeDriver(opt);
  }
  public void GoToURL()
  {
      driver.Navigate().GoToUrl(url);
      WaitForPageLoad();
  }
}
公共类SimpleChrome{
私家镀铬司机;
私有void WaitForPageLoad()
{
var wait=MakeDefaultWait();
等到(x=>((IJavaScriptExecutor)x).ExecuteScript(“returndocument.readyState”).Equals(“complete”);
}
DefaultWait MakeDefaultWait()
{
DefaultWait fluentWait=新的DefaultWait(驱动程序);
fluentWait.Timeout=TimeSpan.FromSeconds(20);
fluentWait.PollingInterval=TimeSpan.Fromms(1000);
IgnoreExceptionTypes(typeof(NoSuchElementException));
fluentWait.Message=“未找到要搜索的元素”;
返回流等待;
}
公共SimpleChrome()
{
ChromeOptions opt=新的ChromeOptions();
opt.AddArgument(“--disable blink features=AutomationControlled”);
选择添加排除的参数(“启用自动化”);
opt.AddAdditionalCapability(“useAutomationExtension”,false);
驱动器=新的色度驱动器(opt);
}
公共无效GoToURL()
{
driver.Navigate().gotour(url);
WaitForPageLoad();
}
}
我尝试做的是创建一个包装器来完成Selenium的工作,它有一个名为
GoTour
的函数。在函数内部,我转到一个url并等待它。当我看到
时,我发现我加载的页面包含了我需要的所有信息。因此,我想将
WaitForPageLoad()
更改为使用XPATH来检测完全加载。XPATH需要处理detect

只需使用

/html

我假设在selenium/browser中使用XPath,dom必须已经完全加载。

“//html”
仅此而已!你可能不想这样做。get方法将在等待您的时候执行其中一些操作。你到底想实现什么?@MosheSlavin,
/
在xpath中有自己的含义。似乎它从当前节点搜索
html
。@Alex我对xpath有点了解。。。当DMart问到你想要完成什么时,//是什么意思,请参见