Tool for quick testing: link
Example 1:
Decision:
Example 1:
Task: XML tree has:
proceedings
-name
-contents
-article
-description
-title
-pages
How can I identify any title that has only one description? And the number of articles that have more than three descriptions using xpath?Decision:
Title with one description:
(note this is not the same as
Example 4:
Xpath:
//*[@id="qualListContainer"]/option[.="HDTV"]
Xpath if number record used:
//*[@id="qualListContainer"]/option[3]
Example 5:
Button that contain link with text "Create"
//button[text()='Create']
the same variant:
//button[.='Create']
or by link text
//a[text()='text_i_want_to_find']/@href
Materials about it:
Stanford's free Introduction to Databases course
Number of articles with more than three descriptions:/proceedings/contents/article[count(
description
)=1]/title
count(/proceedings/contents/article[count(
description
)>3])
Example 2: Find element by span and text
//span[text()='Мероприятия']
next element after f
Example 3:
xpath select first element with attribute
(//*[@id="titleInput"])[1]
This will first get the book elements with the location attribute
equal to 'US'. Then it will select the first node from that set. Note
the use of parentheses, which are required by some implementations.(note this is not the same as
/bookstore/book[1][@location='US']
unless the first element also happens to have that location attribute
)Example 4:
Take element based on text inside (not by number of record)
|
//*[@id="qualListContainer"]/option[.="HDTV"]
Xpath if number record used:
//*[@id="qualListContainer"]/option[3]
Example 5:
Button that contain link with text "Create"
//button[text()='Create']
the same variant:
//button[.='Create']
or by link text
//a[text()='text_i_want_to_find']/@href
Materials about it:
Stanford's free Introduction to Databases course
Комментариев нет:
Отправить комментарий