0
votes

I've been trying to use Selenium to test my application. I wrote the initial tests using the Selenium IDE but, when I converted the IDE tests to Selenium Webdriver tests I got errors for about half of my code! So I'm going through each of the errors trying to get the code to work.

The error I'm getting in Web Driver is

ERROR: Caught exception [Error: unknown strategy [class] for locator [class=x-tool-close]]

In Selenium IDE it had simply been Command Click and target class=x-tool-close.

Thanks,

1

1 Answers

0
votes

It has been awhile since I posted this question so I cannot be sure if I am addressing what the problem was exactly, but with that said the following is what I use for the command I mentioned above.

driver.findElement(By.xpath("//img[contains(@class,'x-tool-close')]")).click();

The structure of this command is very basic. Since the id of my elements are dynamic I search by xpath. Inside the quotation marks we have said xpath. We are searching for an 'img' element whose class attribute contains 'x-tool-close'. Then we are executing the selenium webdriver command click upon that element.