简体   繁体   中英

my selenium test C# in chrome. Click property

While working on this project, I have encountered an exception. It is running firefox, but will not run in chrome.

        [Test]
public void TheBtcTraderDenemeTest()
{
    _driver.Navigate().GoToUrl(_baseUrl);
    Thread.Sleep(1500);
    _driver.FindElement(By.ClassName("btn btn-cust")).Click(); //*** Exception location is this one.

An exception of type 'OpenQA.Selenium.IllegalLocatorException' occurred in WebDriver.dll but was not handled in user code

Additional information: Compound class names are not supported. Consider searching for one class name and filtering the results.

Any ideas on what is going on would be appreciated.

Additional information told you everything. You should choose one of the classes, not both of them

By.ClassName will only accept a single CSS class name, by it's very name & definition. You are giving it two .

Two is 1) btn and 2) btn-cust .

Therefore it's no longer a "class name" selector but rather a general CSS Selector .

So you need to do either of the following:

Use only one of them, probably btn-cust with By.ClassName or keep with what you have but put it into a CSS selector:

By.CssSelector("btn btn-cust")

FWIW, the exception message tells you exactly what is wrong and is saying the exact same thing as we are here. Please check out your exceptions when they are thrown. They aren't there for fun.

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