Nareshkumar
Nareshkumar

Reputation: 1

How to use Xpath for the button in span class?

How to use xpath for the button in span class. (Selenium)

<span class="custom-auto-complete_pic" 
  onclick="supplierParmsCreate.browseSpSupplier();">
</span>

I have tried the below and it's not working

WebElement selectVendor = 
(new WebDriverWait(driver, 10)).until(ExpectedConditions.presenceOfElementLocated(By.xpath("//span[@class='custom-auto-complete_pic']")));
selectVendor.click();

Getting the response as

Exception in thread "main" org.openqa.selenium.ElementNotVisibleException: element not visible (Session info: chrome=43.0.2357.81) (Driver info: chromedriver=2.15.322448 (52179c1b310fec1797c81ea9a20326839860b7d3),platform=Windows NT 6.1 SP1 x86) (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 466 milliseconds Build info: version: '2.45.0', revision: '32a636c', time: '2015-03-05 22:01:35' System info: host: 'C9100970EE83EA7', ip: '172.22.51.106', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.7.0_40' Session ID: 06156aab2bfcf3027acde966a4c24d73 Driver info: org.openqa.selenium.chrome.ChromeDriver Capabilities [{platform=XP, acceptSslCerts=true, javascriptEnabled=true, browserName=chrome, chrome={userDataDir=C:\Users\nxs8519\AppData\Local\Temp\2\scoped_dir17496_10555}, rotatable=false, locationContextEnabled=true, mobileEmulationEnabled=false, version=43.0.2357.81, takesHeapSnapshot=true, cssSelectorsEnabled=true, databaseEnabled=false, handlesAlerts=true, browserConnectionEnabled=false, webStorageEnabled=true, nativeEvents=true, applicationCacheEnabled=false, takesScreenshot=true}] at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:526) at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204) at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:599) at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:268) at org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:79) at com.homedepot.pomt.testSuite.THDParms.createTHDParms(THDParms.java:63) at com.homedepot.pomt.Util.Login.main(Login.java:53)

Upvotes: 0

Views: 755

Answers (1)

kirschmichel
kirschmichel

Reputation: 923

try this. It should be more specific

WebElement selectVendor = 
(new WebDriverWait(driver, 10)).until(ExpectedConditions.presenceOfElementLocated(By.xpath("//span[@onclick='supplierParmsCreate.browseSpSupplier();']")));
selectVendor.click();

Upvotes: 1

Related Questions