The drop down menu that I want to select is store in div so I cannot use the Select() class.
<div waccolumn="" id="segmentoSelect" class="is-3 column"><label class="label">Canal/Segmento</label><div class="control"><ft-segmentos><div class="control"><wac-select><ng-select class="select-custom ng-select ng-select-single ng-select-searchable ng-select-clearable ng-valid ng-touched ng-dirty ng-select-bottom"><div class="ng-select-container"><div class="ng-value-container"><div class="ng-placeholder"></div><!----><!----><div role="combobox" aria-haspopup="listbox" class="ng-input" aria-expanded="false"><input aria-autocomplete="list" type="text" autocorrect="off" autocapitalize="off" autocomplete="ae8bad186fc7" class="user-success"></div></div><!----><!----><span class="ng-arrow-wrapper"><span class="ng-arrow"></span></span></div><!----></ng-select></wac-select></div></ft-segmentos></div></div>
I tried to use a different xpath that have "input" on the tag name:
<input aria-autocomplete="list" type="text" autocorrect="off" autocapitalize="off" autocomplete="ae8bad186fc7" class="user-success" aria-activedescendant="ae8bad186fc7-0" aria-controls="ae8bad186fc7">
and also tried to send the name of the option that I want as key for this path:
rota = automate.bot.find_element_by_xpath("/html/body/app-root/ft-home/div/main/div/wac-escolha-seguimento/ft-escolha-segmento/div/div[1]/div/ft-segmentos/div/wac-select/ng-select/div/div/div[2]/input")
rota.clear
rota.send_keys("ROTA")
It seems to work for the first menu but for the second:
vigencia = automate.bot.find_element_by_xpath("/html/body/app-root/ft-home/div/main/div/wac-escolha-seguimento/ft-escolha-segmento/div/div[2]/div/wac-select/ng-select/div/div/div[2]/input")
vigencia.clear
vigencia.send_keys("ROTA_1_12_2021")
I'm getting this error:
ElementNotInteractableException: Message: element not interactable
(Session info: headless chrome=95.0.4638.69)
How can I select the option and how to know if the click() method worked?
EDIT:
Found a solution for the div problem:
Selecting a combobox option with a <div> tag using Selenium and Python
Now I'm selecting the element that drops down the options and clicking on the option, but still can't open inside selenium the page that the action click on the options would generate.
made a function inside my bot class to select:
def click_elem(self,path):
bot = self.bot
element = bot.find_element_by_xpath(path)
bot.implicitly_wait(10) # seconds
element.click()
drop_down_rota = "/html/body/app-root/ft-home/div/main/div/wac-escolha-seguimento/ft-escolha-segmento/div/div[1]/div/ft-segmentos/div/wac-select/ng-select/div"
drop_down_vigencia = "/html/body/app-root/ft-home/div/main/div/wac-escolha-seguimento/ft-escolha-segmento/div/div[2]/div/wac-select/ng-select/div"
drop_down_unidade = "/html/body/app-root/ft-home/div/main/div/wac-escolha-seguimento/ft-escolha-segmento/div/div[3]/div/wac-select/ng-select/div"
rota = '/html/body/app-root/ft-home/div/main/div/wac-escolha-seguimento/ft-escolha-segmento/div[1]/div[1]/div/ft-segmentos/div/wac-select/ng-select/ng-dropdown-panel/div/div[2]/div[2]'
vigencia = '/html/body/app-root/ft-home/div/main/div/wac-escolha-seguimento/ft-escolha-segmento/div/div[2]/div/wac-select/ng-select'
unidade = "/html/body/app-root/ft-home/div/main/div/wac-escolha-seguimento/ft-escolha-segmento/div/div[3]/div/wac-select/ng-select"
filtrar = "/html/body/app-root/ft-home/div/main/div/wac-escolha-seguimento/ft-escolha-segmento/div/div[4]/wac-button/button"
automate.bot.implicitly_wait(10) # seconds
automate.bot.get("https://freightech.ambev.com.br/#/escolha-segmento")
automate.click_elem(drop_down_rota)
automate.click_elem(rota)
automate.click_elem(drop_down_vigencia)
automate.click_elem(vigencia)
automate.click_elem(drop_down_unidade)
automate.click_elem(unidade)
automate.click_elem(filtrar)
After I click() on filter selenium would supose to show these options:
But when I try to find these elements it return a empty list or an error with "find_element_by_xpath":
automate.bot.find_element_by_xpath('/html/body/app-root/ft-home/div/main/div/wac-escolha-seguimento/ft-escolha-segmento/div[2]/div/div[1]/wac-card-fav/div')
> NoSuchElementException: Message: no such element: Unable to locate
> element:
> {"method":"xpath","selector":"/html/body/app-root/ft-home/div/main/div/wac-escolha-seguimento/ft-escolha-segmento/div[2]/div/div[1]/wac-card-fav/div"}