So when I print the dictionaries alone (price[1] and price[2]) they print the desired output (different outputs), but when I print both at the same time in the same line they produce the same output (both are literally the same)
price[1] = driver.find_elements(By.XPATH, """//div[contains(@aria-label, 'dollars')]""") # Get Prices from Calendar
time.sleep(1.5)
for i in range(3):
print(str(price[1][i].get_attribute("innerHTML")))
#-----------------------------------------
vero = driver.find_element(By.XPATH, """//span[contains(text(),'Next')]/following-sibling::button""") # Click The Next Button
vero.click()
time.sleep(3)
print("\n")
#-----------------------------------------
price[2] = driver.find_elements(By.XPATH, """//div[contains(@aria-label, 'dollars')]""") # Get Prices from Calendar
time.sleep(1.5)
for i in range(3):
print(str(price[2][i].get_attribute("innerHTML")))
So separated from each other they produces an output like this:
$101
$200
$305
$456
$789
$890
But when I try to print them in the same line at the end of the code:
for i in range(3):
print(str(price[1][i].get_attribute("innerHTML")) " <><><> " str(price[2][i].get_attribute("innerHTML")))
It produces this repetition! :
$101 <><><> $101
$200 <><><> $200
$305 <><><> $305
How do I produce this desired outcome? :
$101 <><><> $456
$200 <><><> $789
$305 <><><> $890
CodePudding user response:
If your print statements are OK. This should work, otherwise it seems your Web driver is fetching same data for the two prices.
Price_values_1 = []
for i in range(3):
Price_values_1.append(str(price[1][i].get_attribute("innerHTML")))
#-----------------------------------------
Price_values_2 = []
for i in range(3):
Price_values_2.append(str(price[2][i].get_attribute("innerHTML")))