简体   繁体   中英

Is there a way to select an element that is not an option from a dropdown by text using selenium and C#

Something like this code:

    public void SideMenuNavigateTo(string menuOption)
    {
       this.SideMenu.FindElement(By.XPath("//a[contains(text(),'" + menuOption "')]"));
    }

This code doesn't work, but is there a way to do something similar?

I have found the solution to my problem. The syntax should be a bit different

this.Driver.FindElement(By.XPath(String.Format("//a[contains(text(), '{0}')]", menuOption)));

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