-1

I am trying to automate the Edit portion of LinkedIn Profile. I see that the pen icon for editing my profile is an SVG element and I am unable to locate it using XPATH. Can some one help transforming the XPATH to SVG format so that I can use that ?

Also would appreciate if any proper documentation of the same can be provided. Thanks in advance.

I am using the general XPATH for clicking the icon:

driver.findElement(By.xpath("//svg[@class='artdeco-icon']")).click;

Screenshot URL : https://www.screencast.com/t/d21Ap1XsMVt

Error Log link : https://drive.google.com/open?id=0B-gsMUPbAIhxQTJiSXViZTZlelU

Andersson
  • 51,635
  • 17
  • 77
  • 129
Dannie
  • 27
  • 2
  • 8
  • 1
    You can check out this link (http://stackoverflow.com/questions/41829000/selenium-webdriver-java-how-to-click-on-elements-within-an-svg-using-xpath) which might help you. Else let me know we will help you out. Thanks – undetected Selenium May 12 '17 at 06:37
  • @Dev : Following your link, but wasn't able to understand how to frame the path. Could you please help ? So the idea is to click the SVG Element [Pen Icon per the screenshot] : driver.findElement(By.xpath("//svg[@class='artdeco-icon']")).click; is what I find as the xpath. Thanks – Dannie May 12 '17 at 07:54
  • duplicate of http://stackoverflow.com/questions/30940736/protractor-click-on-svg-element-not-work. there are other threads also where this question is already answer. please search them. – Gaurang Shah May 12 '17 at 08:00
  • Can be specific please about the binding you are using Java/Python/C#/Ruby/JS ? – undetected Selenium May 12 '17 at 09:18
  • Can you update me the manual steps you want to perform once you login to the site? – undetected Selenium May 12 '17 at 09:27
  • Steps : 1. Login to LinkedIn. 2. Go to Your Profile 3. Click on the pen icon as shown in the screenshot : https://www.screencast.com/t/d21Ap1XsMVt Here is where the issue is. I am unable to click on the icon. I am using Java. – Dannie May 12 '17 at 09:32
  • Possible duplicate of [Protractor: Click on SVG element not work](http://stackoverflow.com/questions/30940736/protractor-click-on-svg-element-not-work) – Adrien Blanquer May 12 '17 at 12:35

2 Answers2

2

You can try below XPath expression to match required icon:

//span[text()="Edit Profile"]/following::*[local-name()="svg"]
Andersson
  • 51,635
  • 17
  • 77
  • 129
0

Here is the solution of your Question-

If your testing step is to click the pencil icon to edit your profile, you need to have a closer look into the HTML DOM. The pencil icon is not within any SVG element.

You can click on the pencil icon through:

driver.findElement(By.xpath("//div[@class='core-rail']/section[1]/a[1]")).click();

Let me know if this Answers your Question.

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