'How to verify if the name of image contains 5.0 in its name using c# selenium
Solution 1:[1]
One way you could do this (using js) is with the .indexOf method. In your case, you could use code like this:
// If you gave your img element an id="picture",
// you could get your src text with this line:
var imageSource = document.getElementById("picture").src;
// boolean for whether or not 5.0 exists in the source
var exists = false;
// indexOf will return the index that 5.0 is located at
// if it does not exist, it will return -1
// here, I evaluate if the index of 5.0 is not -1
// if it is not -1, that means it does exist
if (imageSource.indexOf("5.0") != -1)
exists = true;
Here is the w3schools link for the .indexOf method:
https://www.w3schools.com/jsref/jsref_indexof.asp
Yes, this is JavaScript. Which you CAN use: Execute JavaScript using Selenium WebDriver in C#
Hope this helps, good luck!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |

