protractor icon indicating copy to clipboard operation
protractor copied to clipboard

No longer able to select and check checkbox

Open Hardcode37 opened this issue 13 years ago • 8 comments

I am no longer able to select a checkbox and check it using the click event. I used to be able to

driver.findElement(protractor.By.name('terms')).click();

and this would select and check the checkbox, but now this seems to no longer be available.

Hardcode37 avatar Sep 30 '13 13:09 Hardcode37

When did this change happen? Did you update your protractor version? What's the error message you see?

juliemr avatar Sep 30 '13 21:09 juliemr

Ran some more tests this morning and found my project setup caused issues for the check box. However, there are issues with the input locator. This is no longer available to me at all. I am now using name to locate input boxes. the error that is shown is Unsupported locator strategy:findOverride. I assume that findElement by input is only available when using protractor and not the selenium webdriver wrapper. driver = ptor.driver.

There also seems to be a temperamental click event as well.

driver.findElement(protractor.By.id('getQuoteBtn')).click().then(function () {
            ptor.sleep(10000);
            expect(driver.getCurrentUrl()).toContain('cp/quotes');
        });

only seems to bring back the correct url once in every 4-5 attempts. Whereas before the update there was no issue.

Hardcode37 avatar Oct 01 '13 11:10 Hardcode37

Correct, findElement by input is only available on protractor. I assume you're using the driver because you have some polling via $http or $timeout? Otherwise, using ptor will solve your race condition issues.

juliemr avatar Oct 01 '13 23:10 juliemr

No. The routing changed to allow for the removal of the #! and the # so Google can crawl the public views. The view causing the issues uses a c# controller as do all public accessible views so I can not use ptor, I have to use the driver. I guess I will have to sit with the race condition for the short term. Unless you know a way around this. If not I will have to do some more digging around to see if we can get around the race conditions.

Hardcode37 avatar Oct 02 '13 14:10 Hardcode37

Sounds like you're not using standard Angular? I'm not sure what you mean by a c# controller.

There's a section in the Angular documentation on how to get indexing of your Angular application. Go to http://docs.angularjs.org/guide/dev_guide.services.$location and check out the 'crawling your app' header. Maybe that can help?

juliemr avatar Oct 02 '13 16:10 juliemr

To clairfy - Protractor depends on your frontend being written in Angular. What's going on in backend should not matter at all.

juliemr avatar Oct 02 '13 16:10 juliemr

I've checked the routing of the app and it looks like the developer has used window.location to set the redirect url and not used $location.path(). This method has been used because the angular routing is not required at this point as a specific page is required which is served direct from the server rather than angular.

The angular action is below showing the window.location:

$scope.getQuotes = function (quoteForm) {
    if (quoteForm.$valid) {
        $scope.error = false;
        if (checkParcel()) {
            //set field values
            //code omitted
        }
         //trim data and set date
         //code omitted

        $scope.quotesLoading = true;
        QuotesService.getQuotes($scope.collection).then(function (result) {
            window.location = '/cp/quotes';
        }, function (error) {
            $scope.quotesLoading = false;
            errorDialogOptions.resolve = { error: function() { return error.data; } };
            var d = $dialog.dialog(errorDialogOptions);
            d.open();
        });
    } else {
        $scope.error = true;
    }
};

I'll have a look at the webdriver and see if I can combat the race condition, if you know of a way to combat this before I find a solution I would be very grateful.

C# controller is the wrong term, more an asp.net server side controller.

Hardcode37 avatar Oct 03 '13 08:10 Hardcode37

I think this is a server side issue - please open a new issue if you're still having problems.

juliemr avatar Oct 31 '13 18:10 juliemr