Value being returned by Selenium get_attribute() is always 1

I’m doing some amateur web scraping and am having issues with getting a value through an xpath. My target is https://kek.tools/t/0x4e15361fd6b4bb609fa63c81a2be19d873717870. My code looks like:

def scrape_price():
    options = Options()
    options.headless = True
    options.add_argument("--window-size=1920,1200")
    driver = webdriver.Chrome(options=options, executable_path=DRIVER_PATH)
    driver.get('https://kek.tools/t/0x841fad6eae12c286d1fd18d1d525dffa75c7effe')
    driver.implicitly_wait(100)
    price = driver.find_element_by_xpath('//input[@class="sc-ciSkZP sc-bjHqKj bwSYJA dbQnLk" and @tabindex="2"]')
    print(price.get_attribute("value"))
    driver.quit()

In inspect element filtering by //input[@class="sc-ciSkZP sc-bjHqKj bwSYJA dbQnLk" and @tabindex="2"] appears to get the exact input field I need, however “1” is always returned when I print the value. Am I not using the right method for WebElement?

Answer

instead of implicitly_wait try using expected_conditions as following:

from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
def scrape_price():
    options = Options()
    options.headless = True
    options.add_argument("--window-size=1920,1200")
    driver = webdriver.Chrome(options=options, executable_path=DRIVER_PATH)
    wait = WebDriverWait(driver, 20)
    driver.get('https://kek.tools/t/0x841fad6eae12c286d1fd18d1d525dffa75c7effe')
    price = wait.until(EC.visibility_of_element_located((By.XPATH, '//input[@class="sc-ciSkZP sc-bjHqKj bwSYJA dbQnLk" and @tabindex="2"]')))
    print(price.get_attribute("value"))
    driver.quit()