Join the Stack Overflow Community
Stack Overflow is a community of 6.6 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

i want to automate some browser tasks using Python and Selenium webdriver on Chromium browser. My python script is already able to login, navigate to a subpage / do some clicks, and insert something into a form.

My problem is a mandatory dropdown list where i have to choose something before i can go on. I think the webpage contains angularjs / javascript at that point (third line in the code below) to create the dropdown, and i don't know how to handle that.

Problem seem to be 1) to locate the element (xpath seems to change sometimes), and 2) i'm unable to click or send keys to what i've found. Also i've tried some kinds of "WebDriverWait" and sleep commands and "wait.until(expected_conditions.visibility_of_element_located((By.XPATH, ...))"... no luck so far.

Is it at all possible to solve that problem with just Python and Selenium? Or do i need something like Protractor (and does Protractor just works with Javascript commands)? Also i've seen Pytractor...

I'm quite a Newbie concerning that stuff, could someone please explain what could be a good way to solve this problem? Thanks in advance... :)

Webpage code looks like this (grabbed using Firebug/Firepath):

<div class="ng-scope ng-isolate-scope" model-contains-key="true" ref="salutations" cat-input-select="editDetail.salutation">
    <div id="s2id_autogen1" class="select2-container form-control ng-untouched ng-valid ng-dirty ng-valid-parse">
        <a class="select2-choice select2-default" tabindex="-1" href="javascript:void(0)">
            <span id="select2-chosen-2" class="select2-chosen"/>
            <abbr class="select2-search-choice-close"/>
            <span class="select2-arrow" role="presentation">
                <b role="presentation"/>
            </span>
        </a>
        <label class="select2-offscreen" for="s2id_autogen2"/>
        <input id="s2id_autogen2" class="select2-focusser select2-offscreen" type="text" role="button" aria-haspopup="true" aria-labelledby="select2-chosen-2"/>
        <div class="select2-drop select2-display-none select2-with-searchbox">
            <div class="select2-search">
                <label class="select2-offscreen" for="s2id_autogen2_search"/>
                <input id="s2id_autogen2_search" class="select2-input" type="text" aria-autocomplete="list" aria-expanded="true" role="combobox" spellcheck="false" autocapitalize="off" autocorrect="off" autocomplete="off" aria-owns="select2-results-2" placeholder=""/>
            </div>
            <ul id="select2-results-2" class="select2-results" role="listbox"/>
        </div>
    </div>
    <select class="form-control ng-untouched ng-valid ng-dirty ng-valid-parse" ng-change="modelChanged(); changeCallback({value: selectValue.value})" ng-readonly="readonly" ng-disabled="disabled" ng-model="selectValue.value" ui-select2="{dropdownAutoWidth: 'true', allowClear: 'false'}" tabindex="-1" title="" style="display: none;">
        <option value=""/>
        <!-- ngRepeat: option in options -->
        <option class="ng-binding ng-scope ng-isolate-scope" cat-i18n="xxxxxxx.salutation.Mr" value="Mr" ng-repeat="option in options">Mr</option>
        <!-- end ngRepeat: option in options -->
        <option class="ng-binding ng-scope ng-isolate-scope" cat-i18n="xxxxxxx.salutation.Ms" value="Ms" ng-repeat="option in options">Ms</option>
        <!-- end ngRepeat: option in options -->
    </select>
    <!-- ngIf: infoText -->
</div>
share|improve this question

In order to automate any webpage developed in Angular JS, we have to use an opensource tool "Protractor". Selenium itself won't be supporting the Angular JS web applications automation. For more information on Protractor, please refer to the below article

Testing Angular JS application using Protractor

The protractor also uses the same commands which selenium uses.

Hope this helps.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.