Explore Courses Blog Tutorials Interview Questions
0 votes
in DevOps and Agile by (19.7k points)

I want to click on a radio button, appears on a webpage. Code is as follow:

HTML code:

<div class="small-checkbox red-theme raleway-regular text-muted2 position-relative">

        <div class="city-checkbox inline-block position-relative" ng-class="{'rounded-checkbox': main.current_city_id == 1, 'mb-20': main.ifDeviceIsPhone}">

            <label class="mdl-radio mdl-js-radio mdl-js-ripple-effect mh-20" for="mumbaiCity" ng-class="{'is-checked' : main.current_city_id == 1}">

                <input type="radio" id="mumbaiCity" class="mdl-radio__button position-relative vertical-middle" name="city" value="1" ng-click="main.setCity('Mumbai', 1)">

                <span class="mdl-radio__label position-relative font15"><img class="city-icon" src="../../../assets/img/cities/mumbai-icon.png">Mumbai</span>




Test case:

// demo-test.js

describe('Protractor Demo App', function() {

    jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000000;

    it('check item count', function() {





This test throughs error:

1) Protractor Demo App check item count


Failed: element not visible

I also tried with:

element(by.css('[ng-click="main.setCity('Mumbai', 1)"]')).click();

It gives an error:

[16:16:26] E/launcher - Error: SyntaxError: missing ) after argument list

Please suggest, how the radio button will get the click?

1 Answer

0 votes
by (62.9k points)

Use the Explicit wait feature of Selenium and wait till the element is not visible. Once it is visible then you can perform your operations.


The syntax for Explicit wait is as follows:

new WebDriverWait(driver, 30).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//span[text()='index.html']")));


Explanation- In the above code, Selenium will wait 30 seconds until the element is not visible and once it is visible, Selenium will perform an action and will move on to the next step.

Browse Categories