I am struggling to select an element using the text "SELECT PRODUCT" in the following HTML:
<div style="font-family: franklin-gothic-urw; font-weight: 400; font-style: normal; font-size: 19px; opacity: 1; color: rgb(255, 255, 255);">SELECT PRODUCT</div>
Common solutions like this don't seem to work:
driver.findElement(By.cssSelector("div[textContent='SELECT PRODUCT'])
I've experimented with different xpaths and CSS selectors but haven't had any luck.
Although locating the element by its absolute path is possible, we want a more reliable method:
html/body/div[3]/div[1]/div/div[3]/div/div/div/div/div[1]/div/div/div/div/div[2]/div[2]/div/div/div/div/div[2]/div
Using the element's style as a selector won't work either due to similar elements on the page.
I have been searching for a solution for a while now. What is the correct way to locate an element by its text content?