-1

I am trying to find the xpath of svg next to

"//label[@class='btn btn-light p-1']/input[@value='star']

https://9qrcode.com/#link then select Design

enter image description here

Prophet
  • 32,350
  • 22
  • 54
  • 79
Mohamed
  • 95
  • 7
  • What do you mean by "then select Design"? – Prophet Apr 14 '21 at 06:58
  • Also, `//label[@class='btn btn-light p-1']/input[@value='star']` is not unique locator – Prophet Apr 14 '21 at 06:59
  • when yo u open website then click on Design button, you will find pattern, Marker border, Marker center, then view page source, you will see the div, label and input above – Mohamed Apr 14 '21 at 08:39

3 Answers3

1

I hate to do such xpaths, since I agree with Eliyahu - these kind of xpaths won't be unique...but since you asked, here you go, this should work for you:

//input[@value = 'star']/parent::label[contains(@class, 'btn-light')]/preceding-sibling::label[contains(@class, 'btn-light')]/*[name() = 'svg']
Marek
  • 438
  • 5
  • 10
0
//input[@value='star']/preceding::label[@class='btn btn-light p-1'][1]

This will get the preceding element before the value of star which since it's not unique will give two values.

Arundeep Chohan
  • 9,779
  • 5
  • 15
  • 32
0

You can use this xpath -

(//label[contains(@class,"btn btn-light")]/*[local-name() = 'svg'])[2]

your can put your element number in replacing [2].

Swaroop Humane
  • 1,770
  • 1
  • 7
  • 17
  • can we relate the xpath to input[@value='star']???? ie i do not want to use [2], because may be the location will change – Mohamed Apr 14 '21 at 08:36