简体   繁体   中英

I'm trying to select an element I'm working with:

So, written code looks like this:

IWebElement Enter = webDriver.FindElement(By.LinkText("Enter"));

Im trying to get grab a Enter txt from code:

<li>
  <a onclick="javascript:var p;if (document.getElementById('chckPot').checked==true){p=1;}else{p=0;};waitScreen();window.open('frmnewname.aspx?mod=0&amp;pot='+p,'mojframe');" href="#">
    <i class="fa fa-lg fa-folder-open">;</i>
    Enter
  </a>
</li>

So what ever I do I get the following error-message :

OpenQA.Selenium.NoSuchElementException: Unable to find element with LinkText == Enter

Code for test is written in C#, and previous version of app has a ID but new one don't have it (look in code).

部分链接文字可能会在这里有所帮助(可能会有多余的换行符和空格):

IWebElement Enter = webDriver.FindElement(By.PartialLinkText("Enter"));

这是使用xpath处理此问题的方法:

IWebElement element = webDriver.FindElement(By.XPath("//a[contains(text(), 'Enter')]"));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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