URL – https://www.saucedemo.com/inventory-item.html?id=4
How to access the $ mark on this Xpath?
//*[@id="inventory_item_container"]/div/div/div[2]/div[3]/text()[1]
I’m getting an error on IntelliJ:
org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="cart_contents_container"]/div/div[1]/div[3]/div[2]/div[2]/div/text()[1]"}
(Session info: chrome=126.0.6478.185)
expected for below
actualText = driver.findElement(By.xpath("//*[@id="inventory_item_container"]/div/div/div[2]/div[2]")).getText();
for this actual text should be = $.
2
If you want to access the price of the item then you can use find by class because there is a class where “$” is mentioned. Also, the XPATH that you have provided is wrong or incorrect.