We invite future students of the "Java QA Automation Engineer" course and all those interested to watch a demo-lesson in the format of an open webinar.
We also share the translation of a useful article.
XPath .
, - . , , ID, Name, Link, Class, , , .
, () .
=> Selenium .
XPath
, .
, , ID, Name, Class Link, ?
:
, «Log in to Twitter» . , ID
, Class
, Link
Name
, .
Firepath Firefox XPath:
//[@id=âpage-containerâ]/div/div[1]/h1
XPath, id . XPath, , , . , XPath , ID, Class, Link Name.
XPath
«Log in to Twitter», XPath
.
contains() [ ]
starts-with() [ ]
text()
XPath
, contains()
, starts-with()
text()
, «Log in to Twitter» , .
1. Contains()
. - «Log in to Twitter», XPath contains()
.
:
//h1[contains(text(),â Log in toâ)]
//h1[contains(text(),â in to Twitterâ)]
. -.
, contains()
. , . contains()
, , .
, «Log in to Twitter» contains()
.
2. starts-with()
. - «Log in to Twitter», XPath starts-with().
:
//h1[starts-with(text(),âLog inâ)]
//h1[starts-with(text(),âLog in toâ)]
, XPath- starts-with()
(«Log») . , .
, «Log in to Twitter» starts-with()
.
XPath starts-with()
: //h1[starts-with(text(),âin to Twitterâ)]
. , - .
3. text()
. - «Log in to Twitter», XPath
text()
.
, <h1>
</h1>
. text()
, contains()
starts-with()
, .
Xpath text()
:
XPath
XPath
(contains
starts-with
) , . «@
».
:
1. Contains()
. «Iâm Feeling Lucky» (« ») XPath- contains()
, .
â Value
//input[contains(@value,âFeelingâ)]
//input[contains(@value,âLuckyâ)]
, Value
«Feeling» «Lucky» contains()
. , , Value
, .
â Name
//input[contains(@name=âbtnIâ)]
XPath :
contains()
starts-with()
. , .
type
«I'm Feeling Lucky», XPath .
, . type
.
2. starts-with()
starts-with()
, , . , . .
First Name () Surname () .
First Name .
Surname .
, Facebook, id
.
First Name id="u02"
Surname id="u04"
, starts-with()
, id
. , . id
, «u0».
Starts-with() [ id]
//input[starts-with(@id,"u0")]
. .
starts-with
.
11 , XPath , id
«u0». id
(«2» , «4» . .) .
starts-with
, , , .
starts-with
.
/ <strong>Generic Method</strong> /
public void xpathLoc(String identifier){ //The below step identifies the element âFirst Nameâ uniquely when the argument is â2â WebElement E1=d1.findElement(By.xpath("//input[starts-with(@id,âu0â+identifier )]")); E1.sendKeys(âTest1â); / This step enters the value of First Name as âTest 1â / } / <strong>Main Method</strong>*/
public static void main(String[] args) { xpathLoc(â2â); --- This step calls the xpathLoc() method to identify the first name. } |
. Eclipse . , , XPath.
. , , ( ), .
, XPath contains()
, starts-with()
text()
HTML DOM.
XPath:
contains()
XPath, .
starts-with()
XPath, .
contains()
starts-with()
.
text()
XPath, .
text()
.
starts-with()
, XPath .
, XPath XPath -.
, . , 100 ?
.
"Java QA Automation Engineer" .