0

The element I'm trying to access is a dropdown, popup, not sure about this. What's supposed to happen is that I enter an ID into the input field then it takes a few seconds to load and search that in the database, if found it reloads and then I am supposed to click on that in the dropdown. I'm able to locate the element and then enter the required ID, it then reloads but once loaded in the dropdown/popup, I am not able to select that. Below are the screenshots: ( Before | After )

Below is the code I'm using:

elem = all_rows[1].find_element(By.CSS_SELECTOR, "div.MuiAutocomplete-root.autoSearchAutoRoot")
            rt_id_enter = all_rows[1].find_element(By.TAG_NAME, "input")
            rt_id_enter.send_keys(str(df['RT ID'][0]))
            wait = WebDriverWait(driver, 10)
            rt_id_select = all_rows[1].find_element(By.TAG_NAME, "input")
            rt_id_select.click()

The element I am trying to access is a dropdown, popup, not sure about this. What supposed to happen is that I enter an ID into the input field then it takes a few seconds to load and search that in the database, if found it reloads and then I am supposed to click on that in the dropdown. I am able to locate the element and then enter the required ID, it then reloads but once loaded in the dropdown/popup, I am not able to select that.

1
  • The "After" screenshot you posted is not highlighting the "dropdown", it's highlighting the INPUT that you already put the ID into. You can see that because it contains value="39897". You need to find the HTML of the dropdown with "TR for 6th Apr...". We aren't going to be able to help unless you can provide the URL to the site.
    – JeffC
    Commented Apr 11, 2023 at 16:45

1 Answer 1

0

Maybe try replacing this:

wait = WebDriverWait(driver, 10)
rt_id_select = all_rows[1].find_element(By.TAG_NAME, "input")
rt_id_select.click()

With this:

rt_id_select = WebDriverWait(self.driver, 20).until(EC.element_to_be_clickable(all_rows[1].find_element(By.TAG_NAME, "input")))
rt_id_select.click()

you may have to import the following for it to work

from selenium.webdriver.support import expected_conditions as EC

ALTERNATE OPTION

if that doesn't work try using the send keys function to use a combination of the tab key and the enter key to select and click the element. to do the send key command see below:

ActionChains(self.driver).send_keys(keys.TAB).perform()
ActionChains(self.driver).send_keys(keys.ENTER).perform()

you may have to import:

from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
3
  • I tried using this, the problem here is, once I enter the ID into the text box and once it searches this, a dropdown or popup appears with the ID I entered. I am not able to click on that. Commented Apr 11, 2023 at 5:58
  • Hey, it does not works, can we connect directly to address this? Commented Apr 11, 2023 at 7:59
  • I am stuck in this problem for the past 1 day and need to find this out Commented Apr 11, 2023 at 7:59

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.