Click on elements with dyanmic url change in xpath

The below css Selector I have written.

.custom-scrollbar .content-row:nth-of-type(1) [src=’https://static-qa.xxxxxxxxx.com/csp/images/rotate_action_icon.svg’]

enter image description here

Problem is i need to click on that edit button but issue is url changes with respect to env. Example- currently its pointing to qa so the url is qa, if its in prod then it will change due to which web element not found error occurs.

I am trying with below code which doesnot works-

List<WebElement> list = pilot.findElements(By.tagName("img"));
        String aa = list.get(3).getAttribute("src");
        list.get(2).click();

Please suggest a better approach to play around with these buttons with dynamic url.

Answer

Try with following css selector to startswith and endswith

img[src^='https://static-'][src$='com/csp/images/rotate_action_icon.svg']

Leave a Reply

Your email address will not be published. Required fields are marked *