Nazifa Chowdhury
Nazifa Chowdhury

Reputation: 198

xpath and cssSelector for Selenium WebDriver or Selenium RC

I have the following HTML code:

<input type="submit" value="Publish" class="button submit">

I have written xpath as below:

//input[@value='Publish']
//input[@class='button submit']
//input[@type='submit']

What is the corresponding cssSelector for the above xpath for using in Selenium RC or WebDriver test?

Upvotes: 2

Views: 4189

Answers (2)

Ripon Al Wasim
Ripon Al Wasim

Reputation: 37746

         xpath                           cssSelector
//input[@value='Publish']            input[value=Publish]
//input[@class='button submit']      input.button.submit
//input[@type='submit']              input[type=submit]

Upvotes: 3

skunk a
skunk a

Reputation: 245

in order to select your input element you have to write somthing like this

input[type=submit] {
    color: red;
}

the syntax is quite similar to xpath

input[att=val] - Match when the element's "att" attribute value is exactly "val"

Upvotes: 1

Related Questions