i am trying to print the prices from inside the carousel at the top of gog.com.
my script works for some of the prices but not many. i dont understand, theyre basically all the same. i copy and pasted the xpaths, and theyre all basically the same except for their first a tag.
22.99 is at
/html/body/div[2]/div/div[3]/div/div[3]/div[2]/div/a[8]/div[2]/div/div/div[3]/div/span[2]/span
5.69 is at
/html/body/div[2]/div/div[3]/div/div[3]/div[2]/div/a[7]/div[2]/div/div/div[3]/div/span[2]/span
the output i receive is shown below, (the number is printed inbetween the objects. note the empty spaces where there are no numbers)
<selenium.webdriver.remote.webelement.WebElement (session="097dd18658222032f950b705069bfafb", element="3aed9a9c-b010-41e0-a35d-0a2a0d2e98da")>
22.59
<selenium.webdriver.remote.webelement.WebElement (session="097dd18658222032f950b705069bfafb", element="f9dc7bcf-9e1b-482e-9bf7-fd433326f2f3")>
<selenium.webdriver.remote.webelement.WebElement (session="097dd18658222032f950b705069bfafb", element="bd7114ab-8012-4f57-b84d-49e172363cd9")>
my script is below
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium import webdriver
driver = webdriver.Chrome(executable_path=r"../Downloads/chromedriver.exe")
driver.get('https://www.gog.com/')
driver.maximize_window()
WebDriverWait(driver,10).until(EC.presence_of_element_located((By.XPATH,"/html/body/div[2]/div/div[3]/div/div[3]/div[2]/div/a[10]/div[2]/div/div/div[3]/div/span/span")))
A = "/html/body/div[2]/div/div[3]/div/div[3]/div[2]/div/a[4]/div[2]/div/div/div[3]/div/span[2]/span" # this works it print 22.59
print(driver.find_element_by_xpath(A));
print(driver.find_element_by_xpath(A).text);
A = "/html/body/div[2]/div/div[3]/div/div[3]/div[2]/div/a[7]/div[2]/div/div/div[3]/div/span[2]/span" # this doesnt work, it should print 5.69
print(driver.find_element_by_xpath(A));
print(driver.find_element_by_xpath(A).text);
A = "/html/body/div[2]/div/div[3]/div/div[3]/div[2]/div/a[8]/div[2]/div/div/div[3]/div/span[2]/span" # this doesnt work, it should print 22.99
print(driver.find_element_by_xpath(A));
print(driver.find_element_by_xpath(A).text);