我们如何检测使用没有html标签的反应组件构建的网站的web元素(与selenium C#一起使用)?

时间:2018-06-06 11:22:43

标签: c# selenium selenium-chromedriver



 // Navigate to Account Managemnt window
            Thread.Sleep(10000);
            chrome_driver.FindElement(By.XPath("//*[@id='module-menu']/div/button")).Click();
            Thread.Sleep(10000);            
            chrome_driver.FindElement(By.XPath("//*[@id='module-menu']/div/div/button[2]")).Click();
            //*[@id="module-menu"]/div/div/button[2]
            Thread.Sleep(20000);

            IWebElement body = chrome_driver.FindElement(By.TagName("body"));
            var result = chrome_driver.FindElement(By.TagName("body")).Text;
            Console.WriteLine(result);

            IWebElement Single_Acc_Add = chrome_driver.FindElement(By.XPath("//*[@id='single-add-button']/button/span"));
            //chrome_driver.FindElement(By.LinkText("+ Add")).Click();
            action.MoveToElement(Single_Acc_Add).Build().Perform();






<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="theme-color" content="#000000">
    <link rel="manifest" href="/manifest.json">
    <link rel="shortcut icon" href="/favicon.ico">
    <title>PCR Universe</title>
	<link href="/static/css/main.ed365ca1.css" rel="stylesheet">
  </head>
  <body>
      <div
      id="GLOBAL_INFO"
         data-envvar="-siteminder" 
         data-clientname="universal-dashboard" 
         data-clientid="3027d708-26a2-4b63-a131-d672617f46f4" 
         data-domain="azurewebsites.net"  
         data-apienvvar="-siteminder" 
         data-apiname="universalwidgetservice" 
         data-apidomain="azurewebsites.net" 
     data-LOGINURL="https://universal-dashboard-siteminder.azurewebsites.net/authorize"
      data-LOGOUTURL= './Logout.html'
      data-ERRORPAGE= './LoginError.html'
      data-ENCODEDCOOKIE= 'false'
      data-USETOKENAUTH= 'false'
      >
        </div>
    
        <noscript>
          You need to enable JavaScript to run this app.
        </noscript>
        <div id="root"></div>
    	<script type="text/javascript" src="/static/js/main.84c386bd.js"></script>
    </body>
</html>
&#13;
&#13;
&#13;

我正在使用selenium并且遇到了一个不是用java脚本创建但反应元素的网站,如果没有html标签,我怎么能检测到IWebElement。也无法使用链接文本检测它们。

0 个答案:

没有答案