Joseph Shea
Joseph Shea

Reputation: 27

Selenium Find Element by xpath using value as well

I am trying to check to see if buttons are present on a page. The number of buttons varies depending on the type of account that logs in. The code below returns true, so I know that the xpath is working.

Boolean WorkspacePresent = driver2.findElement(By.xpath("//body/div[2]/div[1]/div[1]/form[1]/section[1]/input[1]")).isEnabled(); 

However, I need to make sure that the value is also included, since this just checks how many buttons are there. If I wanted to check for a "Workspace" button, could I still use Find By Xpath?

Upvotes: 1

Views: 269

Answers (1)

KunduK
KunduK

Reputation: 33384

To identify the Workspacebutton button use following xpath.Similar way you can identify other button.

driver2.findElement(By.xpath("//input[@name='Workspacebutton' and value='Workspace']"))

Upvotes: 2

Related Questions