Used By: WebDriver, C #

Code:

link = browser1.FindElements(By.CssSelector(a[href*=ibm])).ToList(); 

Extract links and get links in two categories. see screen enter image description here

And it is required to retrieve Category 1 links. I tried to change the selector to a[href*=ibm.com] , as well as other interpretations.

As a result, CssSelector stops working.

Question: How to choose the CssSelector , that links of the required domain were extracted?

    2 answers 2

    Many possible options. How about checking that the link ends in ?lnk=flg :

     a[href$="?lnk=flg"] 

    $= here means "ends with".

    Another option is to check what starts at http://www.ibm.com :

     a[href^="http://www.ibm.com"] 

    I don’t really like both options, but they may turn out to be practical and suitable for your situation.

      As far as I understand, you need xpath like this:

       //a[contains(@href,'ibm.com')]