Wednesday, November 19, 2014

On 1:03 AM by Unknown   No comments
Answer 24CSS location strategy can be used with Selenium to locate elements, it works using cascade style sheet location methods in which -

Direct child is denoted with – (a space)
Relative child is denoted with - > Id, class, names can also be used with XPath –
  • css=input[name=’q’]
  • css=input[id=’lst-ib’] or input#lst-ib
  • css=input[class=’ lst’] or input.lst 

If only part of id/name/class is constant than “contains” can be used as –
  • css=input[id*=' lst-ib ')]

Element location strategy using inner text
  • css = a:contains(‘log out’)


Answer 25If there is constant name/id available then you should use instead of XPath and CSS locators. If not then CSS locators should be given preference as their evaluation is faster than XPath in most modern browsers.

Answer 26This can be achieved by executing java script in Selenium. Java script can be executed using following syntax –

Type(Command)             css=input#s (Target)           javascript{Math.random()}(value)
And for date –
Type (Command)             css=input#s(Target)             javascript{new Date()}(value)



0 comments:

Post a Comment