1

I am trying to automate testing of a website. I manage to open it in Firefox (but this could be changed if necessary) and populate some fields. I am using Selenium and Python.

I am now stuck trying to select elements from a drop-down-list:

enter image description here

I cannot, however, seem to find an ID, name, or other working identifier for the dropdown list. When I save the entire website code as html and search through it, the currencies listed are not found in the source code.

When I click ctrl + shift + c to inspect the page and click on the inner field that currently shows "EUR" , the following code is highlighted (linebreaks added by me):

<input type="text" class="mw-dropdown-input-field ng-pristine ng-valid ng-isolate-scope mw-dropdown-input-enabled ng-touched ng-not-empty" 
ng-class="getInputClass()" ng-model="editModel" edit-change="editChange()" 
edit-change-mode="editChangeMode" input-cut="editModelCut" ng-readonly="ngDisabled" 
ng-style="inputStyle" ng-keydown="inputKey($event, true, true, false, true)" 
tabindex="100" style="background-image: url(&quot;/img/mandatory.png&quot;);
background-position: right bottom; background-repeat: no-repeat; 
background-color: rgb(255, 255, 200); color: rgb(0, 0, 0);">

When I click on the dropdown-arrow, the outer field and the following code is highlighted:

<div class="mw-dropdown-caret-parent" ng-show="!ngDisabled &amp;&amp; 
(values || dropdownContents || type === 'calendar')" 
ng-click="dropdown()"><div class="caret"></div></div>

None of these contain the list of currencies that I should be able to select from. From what I can see, this eliminates suggestions that were answers to similar questions here.

I cannot post the site's entire html code, but here is a screenshot of the, I believe, relevant part in the html code, which contains the two snippets from above:

enter image description here

Marie. P.
  • 255
  • 1
  • 4
  • 17
  • 1
    Make a click, instruct selenium to wait (explicitly or until the item is presented), and then retrieve the element. – ipaleka Jul 24 '19 at 11:54
  • Thank you, that sounds good, but can you suggest at what exactly I should click? I tried using `driver.find_element_by_css_selector("input mw-dropdown-input-field ng-pristine ng-untouched ng-valid ng-isolate-scope mw-dropdown-input-enabled ng-not-empty").click()` but it is "unable to locate element". How can I locate these elements, except manually deriving the `xpath` by going through the `html` and counting the levels of each `div` entry? – Marie. P. Jul 24 '19 at 11:59
  • It comes down to trying. Select elements by class and look inside that list to identify your element. – ipaleka Jul 24 '19 at 12:09

0 Answers0