2013-08-14 2 views
1

casperjs가 특정 x, y 위치를 클릭하도록 할 수 있습니까? 기본적으로 캔버스 (캔버스의 특정 지점을 클릭)와 상호 작용하려고하지만이를 수행하는 방법을 모릅니다. 그럴 수 없다면 이것을 할 수있는 프론트 엔드 라이브러리가 있습니까?casperjs가 특정 지역을 클릭 할 수 있습니다.

감사 팬텀 API에 액세스

+0

프론트 엔드? casperjs는 phantomjs를 기반으로합니다. 캐스퍼에'click (x, y)'가 있는지 확실하지 않지만 phantom API에 액세스 할 수있는 경우 : [SendEvent] (https://github.com/ariya/phantomjs/wiki/API-Reference-WebPage # sendeventmouseeventtype-mousex-mousey-buttonleft-or-sendeventkeyboardeventtype-keyorkeys-null-null-modifier) ​​ – fusio

답변

1

시도 :

casper.then(function() { 
    this.page.sendEvent(...) 
}); 
+0

casperjs에서 phantomJs 특정 API를 어떻게 실행합니까? – Saad

+0

'casper.page'는 PhantomJS 웹 페이지에 대한 참조입니다. 당신은'casper.page.sendEvent ("mouse ..", ..)'할 수 있어야한다. – fusio

0

CasperJS 당신이 어딘가에 mouse.click를 배치하는 데 사용할 수있는 mouse 모듈을 제공합니다.

먼저 캔버스 영역을 검색 한 다음 캔버스 요소를 기준으로 클릭을 배치하는 것이 좋습니다.

casper.relativeClick = function(selector, x, y){ 
    var info = this.getElementInfo(selector); 
    if (x < info.width && y < info.height) { 
     x += info.x; 
     y += info.y; 
     this.mouse.click(x, y); 
    } else { 
     console.log("warning: click out of bounds"); 
    } 
} 

당신은 다음 단계 (then* 또는 wait*) 내부를 호출 할 수 있습니다 : 당신은 그런 자신의 기능을 할 수 있습니다.

관련 문제