My Team " />

web element with part x path and text

2018-03-09 08:55:40

I have web element set like below ..

My Team

There, the number in GHC1 change depending on place, but text "My Team" is unique for particulate set of element.

I tried to locate it with

By.XPATH,'//*[contains(@id,"ctl00_LeftPanel_LeftNavigationMenu_nbMenu_GHC") AND contains(text()="My Team")]'

But failed.

how to do that correctly ? can not use by.text since "My Team" text could be exist other parts of web page

IF text "My Team" is unique for particular set of element then as per my understanding we are not having 'My Team' anywhere on the page, We can directly use syntax:

//div[text()='My Team']

//div[contains(text(),'My Team')]

Most of the software testing services company use the same approach. If you want to use the syntax provide by you then you can directly concatenate the text with t

  • IF text "My Team" is unique for particular set of element then as per my understanding we are not having 'My Team' anywhere on the page, We can directly use syntax:

    //div[text()='My Team']

    //div[contains(text(),'My Team')]

    Most of the software testing services company use the same approach. If you want to use the syntax provide by you then you can directly concatenate the text with the id without using AND also like:

    //div[contains(@id,'ctl00_LeftPanel_LeftNavigationMenu_nbMenu')][text()='My Team']

    //div[contains(@id,'ctl00_LeftPanel_LeftNavigationMenu_nbMenu')] AND [text()='My Team']

    //div[contains(@id,'ctl00_LeftPanel_LeftNavigationMenu_nbMenu')] [contains(text()='My Team')]

    //div[contains(@id,'ctl00_LeftPanel_LeftNavigationMenu_nbMenu')] AND [contains(text()='My Team')]

    Please let me know if the syntax provided above is working.

    2018-03-09 10:23:48