Search code examples
pythonseleniuminputtextboxelement

can't find text box element by xpath or css selector


I am trying to enter some text into a text box on a webpage, here is the screenshot screenshot for Enter Symbol.

My code works fine for all other elements except for the highlighted text box in the screenshot:

WebDriverWait(driver, 40).until(EC.visibility_of_element_located((By.XPATH, '//*[@id="main-content-column"]/div/div[3]/div/div[1]/form/div/div/div[2]/input'))).send_keys("aapl")

It doesn't look like in a frame or iframe. Please see the source code for the website:

<input type="text" autocomplete="off" autocorrect="off" autocapitalize="off" placeholder="Add a symbol..." class="sec-search-box bc-form__add-symbol-input ng-pristine ng-invalid ng-invalid-required ng-touched placeholder" data-ng-model="userEnteredSymbols" data-barchart-clear-input="" required="">

Thanks a lot.


Solution

  • You can input the value using the xpath:

    WebDriverWait(driver, 40).until(EC.visibility_of_element_located((By.XPATH, "//input[@data-ng-model='userEnteredSymbols']"))).send_keys("aapl")