Select Item Inside A React-select Dropdown List In Selenium With Python
Link example website here In that website, I am looking how to select item (e.g 'Green') in 'Single' dropdown box and 'Grouped' dropdown box. I tried to click to dropdown first and
Solution 1:
remove @ from text
driver.find_element_by_xpath("//*[text()='Green']").click()
To click on options that are not visible:
option=driver.find_element_by_xpath("//*[text()='Silver']")
driver.execute_script("arguments[0].scrollIntoView();", option)
option.click()
You have to scroll first to that and then click
Solution 2:
To select Green from the Single dropdown box you need to induce WebDriverWait for the element_to_be_clickable()
and you can use either of the following Locator Strategies:
driver.get("https://react-select.com/home")
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "div.basic-single > div.select__control > div.select__value-container"))).click()
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//div[contains(@class, 'select__menu')]/div[contains(@class, 'select__menu-list')]//div[contains(@class, 'select__option') and text()='Green']"))).click()
- Browser Snapshot:
Post a Comment for "Select Item Inside A React-select Dropdown List In Selenium With Python"