Below is the XPATH I am using to extract price information from various websites, except for Myntra. This XPATH works perfectly on my local Windows system with Selenium, Python3 version, and Chrome driver.
Driver path:
driver = webdriver.Chrome("/usr/lib/chromium-browser/chromedriver", options=chrome_options);
Variable name:
driver.find_element_by_xpath('//*[@id="mountRoot"]/div/div/div/main/div[2]/div[2]/div[1]/p[1]/span/strong').text
For reference, visit this link:
When deployed on an EC2 Ubuntu machine, I encountered the following error message: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="mountRoot"]/div/div/div/main/div[2]/div[2]/div[1]/p[1]/span/strong"}
I attempted to modify the XPATH to
driver.find_element_by_xpath('//*[@class="pdp-price"]//*').text
, but it was not successful.