-2

I have tried like this:

//*[name()='svg']/*[name()='path' and contains(@d, 'M290.74 93.24l128.02']

but it throws exception.

If we use "//*[name()='svg']/*[name()='path'" like this, then it's giving all elements but it's not my actual requirement.

Here I posting some pictures, Please some one help me on this. I tried many ways but I didn't make this possible.

enter image description here

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352

3 Answers3

-1

Try getting the selector by inspecting the element and in the Inspector right click the element and copy the css selector.

enter image description here

James Webb
  • 167
  • 2
  • 17
  • @Rob this is a picture of the context menu. Not the code, data or error messages. The text has also been typed into the question already. Please explain what the issue is? – James Webb Jan 18 '21 at 11:24
-1

The desired element is the only descendent <path> element of it's parent <svg> element so to Click() on the element you have to induce WebDriverWait for the ElementToBeClickable() and you can use either of the following Locator Strategies:

  • XPath:

    new WebDriverWait(driver, TimeSpan.FromSeconds(20)).Until(ExpectedConditions.ElementToBeClickable(By.XPath("//h5[text()='Brandes Intl Equity']//following::*[name()='svg' and @data-icon='pen'][@role='img']/*[name()='path']"))).Click();
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
-2

Try to select icon based on sibling header value

"//*[name()='svg' and @data-icon='pen']/*[name()='path']"
JaSON
  • 4,843
  • 2
  • 8
  • 15
  • While this code may answer the question, providing additional context regarding how and/or why it solves the problem would improve the answer's long-term value. – Tomer Shetah Jan 18 '21 at 11:17
  • I can't decide which one I need click, So I can't use the h5 tag here ```//h5[.='Brandes Intl Equity']```. It was decided based on the grayed out pencil icon. – Chenchu babu Jan 18 '21 at 13:11
  • @Chenchubabu OK, if you don't want to use `h5` in your XPath, then try `"//*[name()='svg' and @data-icon='pen']/*[name()='path']"` – JaSON Jan 18 '21 at 13:34