D
D
Dima2016-12-01 01:28:41
JavaScript
Dima, 2016-12-01 01:28:41

Clicking on vk.com via casperjs doesn't work, what's wrong?

Good afternoon!
I'm trying a fairly simple operation - changing the notification settings for the mail for the VKontakte account via casperJS, the following code (fragment):

casper.open('https://vk.com/settings?act=notify').then( function() {
        casper.wait ('5000', function () {
            this.clickLabel('Every time', 'a');
            this.clickLabel('Don\'t send', 'div');
        })

        this.capture('vk.png');

actually I open the page, I click on the button to change the number of notifications to the mail, I choose never, I make a screen.
I look at the screen - everything is OK, the desired item is selected.
I check the account - the setting did not apply ...
I tried to press in different ways, both by the button class and by ID, the result is the same.
In the process of debugging, sometimes it was possible to achieve the desired result, but then it still failed. I can’t imagine what could be the problem, since all operations are very simple. I sin on a timeout, a sequence of actions.
If there are other options for simple automation of this task, I am ready to consider them.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vlad Volynets, 2016-12-01
@Di9

With such tools, there is usually a problem with timeouts and execution sequence, try to play with timeouts, set a timeout between actions, it should work.

R
Rou1997, 2016-12-01
@Rou1997

Isn't it necessary to do it Submitwith the "Save" button, etc.?
If not, it means that an HTTP request should be sent immediately when clicked, so with the help of a sniffer like Fiddler, see if it is sent, what answer comes in, what is the problem, actually using a sniffer you can solve the problem without any Casper.js by imitating HTTP requests in any language, and without a sniffer you don’t fully approach the task, you also don’t have general debugging skills (use stacktrace, “hooks” on XMLHttpRequest, etc.), you need to acquire them, then everything will become transparent and will not be so stupid questions, and without them, such programming is also not complete.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question