Skip to main content
deleted 666 characters in body
Source Link
Michael Durrant
  • 25.2k
  • 3
  • 41
  • 113

You'll need a better approach.

Please post the HTML in question, not just a link to the site. The link is helpful but we'd like the code here too please. The site will go away or change and that would make the question hard to understand.

You should not use the _1UoZIX identifier. It's generated on the fly (dynamically) and changes over time. It also has no semantic meaning, doesn't say fridge at all

To get to that specific image

alt="Godrej 260 L Frost Free Double Door Refrigerator" 

is an attribute I would consider basing my locator on in comparison to the layout and react id's. Even that is text based and not a great selector but the page in question is not well constructed for other tag identifiers for this image as far as I can see. You could use *fridge* perhaps on the alt tag.

However, gettingGetting to the 'first search result image' element generically, i.e. first result and not just when it is that fridge... is going to be a challenge given the layout. One approach that might work is (pseudo code) a locator that is something like

//div a[@href='/']/img[2]

i.e. find the main div based on the home anchor within it and then look for the second image within that div. I don't like this much but this is due to the page structure presented. Some version of this may work.

Also, unless you use relative addressing I prefer css locators for readability and compactness, e.g.

div a[href=''] img:nth-child(2)

In this case the CSS identifier is longer but that is fairly unusual.

You'll need a better approach.

Please post the HTML in question, not just a link to the site. The link is helpful but we'd like the code here too please. The site will go away or change and that would make the question hard to understand.

You should not use the _1UoZIX identifier. It's generated on the fly (dynamically) and changes over time. It also has no semantic meaning, doesn't say fridge at all

To get to that specific image

alt="Godrej 260 L Frost Free Double Door Refrigerator" 

is an attribute I would consider basing my locator on in comparison to the layout and react id's. Even that is text based and not a great selector but the page in question is not well constructed for other tag identifiers for this image as far as I can see. You could use *fridge* perhaps on the alt tag.

However, getting to the 'first search result image' element generically, i.e. first result and not just when it is that fridge... is going to be a challenge given the layout. One approach that might work is (pseudo code) a locator that is something like

//div a[@href='/']/img[2]

i.e. find the main div based on the home anchor within it and then look for the second image within that div. I don't like this much but this is due to the page structure presented. Some version of this may work.

Also, unless you use relative addressing I prefer css locators for readability and compactness, e.g.

div a[href=''] img:nth-child(2)

In this case the CSS identifier is longer but that is fairly unusual.

You should not use the _1UoZIX identifier. It's generated on the fly (dynamically) and changes over time. It also has no semantic meaning, doesn't say fridge at all

Getting to the 'first search result image' element generically, i.e. first result and not just when it is that fridge... is going to be a challenge given the layout. One approach that might work is (pseudo code) a locator that is something like

//div a[@href='/']/img[2]

i.e. find the main div based on the home anchor within it and then look for the second image within that div. I don't like this much but this is due to the page structure presented. Some version of this may work.

Also, unless you use relative addressing I prefer css locators for readability and compactness, e.g.

div a[href=''] img:nth-child(2)

In this case the CSS identifier is longer but that is fairly unusual.

added 603 characters in body
Source Link
Michael Durrant
  • 25.2k
  • 3
  • 41
  • 113

You'll need a better approach.

Please post the HTML in question, not just a link to the site. The link is helpful but we'd like the code here too please. The site will go away or change and that would make the question hard to understand.

You should not use the _1UoZIX identifier. It's generated on the fly (dynamically) and changes over time. It also has no semantic meaning, doesn't say fridge at all

To get to that specific image

alt="Godrej 260 L Frost Free Double Door Refrigerator" 

is an attribute I would consider basing my locator on in comparison to the layout and react id's. Even that is text based and not a great selector but the page in question is not well constructed for other tag identifiers for this image as far as I can see. You could use *fridge* perhaps on the alt tag.

However, getting to the 'first search result image' element generically, i.e. first result and not just when it is that fridge... is going to be a challenge given the layout. One approach that might work is (pseudo code) a locator that is something like

//div a[href='a[@href='/']../img[2]

i.e. find the main div based on the home anchor within it, go back up one level (xpath relative addressig) and then look for the second image within that div. I don't like this much but this is due to the page structure presented. Some version of this may work. You'll need to read up on xpath

Also, unless you use relative addressing if you don't know it alreadyI prefer css locators for readability and compactness, e.g.

div a[href=''] img:nth-child(2)

fyi The ability to transverse relative paths isIn this case the only reason I will use an XPATH locator over CSS and so itidentifier is very rare in my experiencelonger but that is fairly unusual.

You'll need a better approach.

Please post the HTML in question, not just a link to the site. The link is helpful but we'd like the code here too please. The site will go away or change and that would make the question hard to understand.

You should not use the _1UoZIX identifier. It's generated on the fly (dynamically) and changes over time. It also has no semantic meaning, doesn't say fridge at all

To get to that specific image

alt="Godrej 260 L Frost Free Double Door Refrigerator" 

is an attribute I would consider basing my locator on in comparison to the layout and react id's. Even that is text based and not a great selector but the page in question is not well constructed for other tag identifiers for this image as far as I can see. You could use *fridge* perhaps on the alt tag.

However, getting to the 'first search result image' element generically, i.e. first result and not just when it is that fridge... is going to be a challenge given the layout. One approach that might work is (pseudo code) a locator that is something like

//div a[href='/']../img[2]

i.e. find the main div based on the home anchor within it, go back up one level (xpath relative addressig) and then look for the second image within that div. I don't like this much but this is due to the page structure presented. Some version of this may work. You'll need to read up on xpath relative addressing if you don't know it already.

fyi The ability to transverse relative paths is the only reason I will use an XPATH locator over CSS and so it is very rare in my experience.

You'll need a better approach.

Please post the HTML in question, not just a link to the site. The link is helpful but we'd like the code here too please. The site will go away or change and that would make the question hard to understand.

You should not use the _1UoZIX identifier. It's generated on the fly (dynamically) and changes over time. It also has no semantic meaning, doesn't say fridge at all

To get to that specific image

alt="Godrej 260 L Frost Free Double Door Refrigerator" 

is an attribute I would consider basing my locator on in comparison to the layout and react id's. Even that is text based and not a great selector but the page in question is not well constructed for other tag identifiers for this image as far as I can see. You could use *fridge* perhaps on the alt tag.

However, getting to the 'first search result image' element generically, i.e. first result and not just when it is that fridge... is going to be a challenge given the layout. One approach that might work is (pseudo code) a locator that is something like

//div a[@href='/']/img[2]

i.e. find the main div based on the home anchor within it and then look for the second image within that div. I don't like this much but this is due to the page structure presented. Some version of this may work.

Also, unless you use relative addressing I prefer css locators for readability and compactness, e.g.

div a[href=''] img:nth-child(2)

In this case the CSS identifier is longer but that is fairly unusual.

added 603 characters in body
Source Link
Michael Durrant
  • 25.2k
  • 3
  • 41
  • 113

You'll need a better approach.

Please post the HTML in question, not just a link to the site. The link is helpful but we'd like the code here too please. The site will go away or change and that would make the question hard to understand.

You should not use the _1UoZIX identifier. It's generated on the fly (dynamically) and changes over time. It also has no semantic meaning, doesn't say fridge at all

So far I'm seeingTo get to that specific image

alt="Godrej 260 L Frost Free Double Door Refrigerator" 

as the onlyis an attribute I would consider basing my locator on in comparison to the layout and react id's. Even that is text based and not a great selector but the page in question is not well constructed for other tag identifiers for this image as far as I can see. You could use *fridge* perhaps on the alt tag.

However, getting to the 'first search result image' element generically, i.e. first result and not just when it is that fridge... is going to be a challenge given the layout. One approach that might work is (pseudo code) a locator that is something like

//div a[href='/']../img[2]

i.e. find the main div based on the home anchor within it, go back up one level (xpath relative addressig) and then look for the second image within that div. I don't like this much but this is due to the page structure presented. Some version of this may work. You'll need to read up on xpath relative addressing if you don't know it already.

fyi The ability to transverse relative paths is the only reason I will use an XPATH locator over CSS and so it is very rare in my experience.

You'll need a better approach.

Please post the HTML in question, not just a link to the site. The link is helpful but we'd like the code here too please. The site will go away or change and that would make the question hard to understand.

You should not use the _1UoZIX identifier. It's generated on the fly (dynamically) and changes over time. It also has no semantic meaning, doesn't say fridge at all

So far I'm seeing

alt="Godrej 260 L Frost Free Double Door Refrigerator" 

as the only attribute I would consider basing my locator on. Even that is text based and not a great selector but the page in question is not well constructed for other tag identifiers for this image as far as I can see. You could use *fridge* perhaps on the alt tag.

You'll need a better approach.

Please post the HTML in question, not just a link to the site. The link is helpful but we'd like the code here too please. The site will go away or change and that would make the question hard to understand.

You should not use the _1UoZIX identifier. It's generated on the fly (dynamically) and changes over time. It also has no semantic meaning, doesn't say fridge at all

To get to that specific image

alt="Godrej 260 L Frost Free Double Door Refrigerator" 

is an attribute I would consider basing my locator on in comparison to the layout and react id's. Even that is text based and not a great selector but the page in question is not well constructed for other tag identifiers for this image as far as I can see. You could use *fridge* perhaps on the alt tag.

However, getting to the 'first search result image' element generically, i.e. first result and not just when it is that fridge... is going to be a challenge given the layout. One approach that might work is (pseudo code) a locator that is something like

//div a[href='/']../img[2]

i.e. find the main div based on the home anchor within it, go back up one level (xpath relative addressig) and then look for the second image within that div. I don't like this much but this is due to the page structure presented. Some version of this may work. You'll need to read up on xpath relative addressing if you don't know it already.

fyi The ability to transverse relative paths is the only reason I will use an XPATH locator over CSS and so it is very rare in my experience.

Source Link
Michael Durrant
  • 25.2k
  • 3
  • 41
  • 113
Loading