1

I am trying to select an option(not from the dropdown) and then click on the button. The problem is I cannot find any class name, id or name or any selector to find that element.List

I tried "By.className="device pcclient selected" but an error occurs "Compound class names not permitted". How can I select an option from R1, R2, R3 and then click on the button.

cruisepandey
  • 28,520
  • 6
  • 20
  • 38
  • 2
    While the below answer may solve the error `compound class names not permitted`, It's easy for us to make a replica of UI if HTML was shared in text format. also after selecting `R1, R2, R3` which button you want to click. – cruisepandey Jan 22 '22 at 14:10

1 Answers1

0

You get the error "Compound class names not permitted" when there are spaces in the class name and you try to find that element by using the className method. For more info on the error, you can refer this link.

You can try finding the desired element by xpath and click on it as shown below:

//Clicking R1
driver.findElement(By.xpath("//li[@class='device pcclient']/a[contains(text(),'R1')]").click();

//Clicking R2
driver.findElement(By.xpath("//li[@class='device pcclient']/a[contains(text(),'R2')]").click();

//Clicking R3
driver.findElement(By.xpath("//li[@class='device pcclient']/a[contains(text(),'R3')]").click();
Gurmanjot Singh
  • 10,224
  • 2
  • 19
  • 43
  • 1
    Thanks a lot @Gurmanjot. It solved the problem, also the link you shared is really helpful as I just started learning Selenium with Java. – Rizwana Alamgir Jan 22 '22 at 15:52