I already deal with it for many days having no idea how to solve it...
That is the element I want to get by selenium
<input name="QUICKSEARCH_STRING" id="QUICKSEARCH_STRING" onfocus="setTimeout('focusSearchElem()', 100);" type="text" value="">
They all pop out the warning like this one
===>
Message: no such element: Unable to locate element: {"method":"css selector","selector":"[name="QUICKSEARCH_STRING"]"} (Session info: chrome=79.0.3945.88)
It is my code:
import selenium.webdriver
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.action_chains import ActionChains
my_driver = selenium.webdriver.Chrome()
account_box=my_driver.find_element_by_id('j_username')
account_box.send_keys('my_user_name')
#### I tried many ways to get the element####
#way 1(get the elemnt by full xpath):
my_driver.implicitly_wait(10)
PlmSearchBox=my_driver.find_element_by_xpath("/html/body/div[5]/div[3]/form/div/div[3]/input") #doesn't work
#
#way 2(get the element by name):
my_driver.implicitly_wait(10)
PlmSearchBox=my_driver.find_element_by_name('QUICKSEARCH_STRING') #doesn't work
#
#way 3(get the element by xpath):
my_driver.implicitly_wait(10)
PlmSearchBox=my_driver.find_element_by_xpath('//*[@id="QUICKSEARCH_STRING"]') #doesn't work
#
#way 4(get the element by id):
my_driver.implicitly_wait(10)
PlmSearchBox=my_driver.find_element_by_id('QUICKSEARCH_STRING') #doesn't work
#
#way 5(get the element by using explicit wait):
PlmSearchBox=wait.until(selenium.webdriver.support.expected_conditions.presence_of_element_located((By.ID, "QUICKSEARCH_STRING"))) #doesn't work
#
PlmSearchBox.send_keys('93-55520-300E')
#############################################
And after trying those ways and failed, I noticed that the cursor is blinking in the input box which I want to send the key to.
So I use
ActionChains
PlmSearchBox = ActionChains(my_driver)
PlmSearchBox.send_keys('93-55520-300E')
PlmSearchBox.perform()
There isn't any error message poping out, but the input box still remains blank.
switch_to.active_element
PlmSearchBox=my_driver.switch_to.active_element
PlmSearchBox.clear
PlmSearchBox.send_keys('93-55520-300E')
The result is as same as ActionChains.
I will really appreciate that someone tells me what's wrong with my code.