1

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?

enter image description here

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:

enter image description here

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"}
Carol Vieira
  • 69
  • 2
  • 9
  • 1
    Update the question with the relevant HTML and your code trials. – undetected Selenium Dec 15 '21 at 17:08
  • @DebanjanB thanks! – Carol Vieira Dec 15 '21 at 17:35
  • 1
    Normally on div tags you want to invoke .click() on the element that drops down the elements. Then .click() on the element which drops down. – Arundeep Chohan Dec 15 '21 at 21:13
  • @ArundeepChohan Is there anyway to know if the click() worked? because I did that and can't click on tags that were supose to be shown after I selected the drop down options – Carol Vieira Dec 15 '21 at 21:19
  • Are you running this headless? If so, run it with the browser open to see how it is interacting with the page. This way, you should be able to figure out if the click() is working as expected. This is what I have done in the past. You might also need to wait a second to see if the list is dynamic and needs a bit to populate. – A_Patterson Dec 16 '21 at 19:17

0 Answers0