0

I have this element

<div class="btn">
<input type="submit" ng-disabled="form.$invalid" ng-click="submit(user)" value="Sign In" />
</div>

that submits login data. I tried following ways, but they not working:

$('div[class="btn"] > input').click();
$('div[class="btn"] > input').submit();

How to submit by other way?

Eldar Agalarov
  • 4,849
  • 4
  • 30
  • 38
  • I'm using version 2.0 without Casper. – Eldar Agalarov Oct 29 '15 at 12:56
  • Sorry, used the wrong template. Here is the correct one: Please register to the `onConsoleMessage`, `onError`, `onResourceError`, `onResourceTimeout` events ([Example](https://gist.github.com/artjomb/4cf43d16ce50d8674fdf#file-1_phantomerrors-js)). Maybe there are errors. – Artjom B. Oct 29 '15 at 13:07
  • Are you sure that the page has fully loaded and the elements are there? Have you taken a screenshot to see if they are? – Artjom B. Oct 29 '15 at 13:08
  • Yes, login form is visible on a screenshot. – Eldar Agalarov Oct 29 '15 at 13:32

1 Answers1

1

jQuery's events are maintained in local scope, and using an injected jQuery to click from PhantomJS will not necessarily invoke the event you want--you'd have to obtain a handle to the page jQuery.

However, you're probably trying to test user behavior. A better test is to dispatch a click as a user event, as described here: PhantomJS; click an element

Community
  • 1
  • 1
Palpatim
  • 9,074
  • 35
  • 43