learner
learner

Reputation: 39

How to extract XPATH or CSSPath from a web element in selenium java

I want to feed values to input fields which have no name, no id or no class.

<form class="formclass">
  <input type="text">
  <input type="password">
</form>`

Upvotes: 0

Views: 274

Answers (2)

FayazMd
FayazMd

Reputation: 386

Please try the following

xpath:

(//form[@class='formclass]//input)[0] 
(//form[@class='formclass]//input)[1]

css:

.formclass input[type='text']
.formclass input[type='password']

Upvotes: 0

Andersson
Andersson

Reputation: 52695

Try XPath

//form[@class="formclass"]/input[@type="text"]
//form[@class="formclass"]/input[@type="password"]

or CSS selector

form.formclass input[type="text"]
form.formclass input[type="password"]

Upvotes: 1

Related Questions