Clicking on a Hyperlink in PhantomJS
Hi,
I am trying to automate login on a website and i m able to fill the username and password in the field. But when i try to click on "sign in" nothing is happening. Later when i inspected the element i found that its a hyperlink.
Can you please suggest me a way to trigger an event to that hyperlink,
@jobinsjohn Hi, your problem sloved?
@wcccode Yeah i solved the problem and found a way to solve it. But now i am facing another situation which i am not able to tackle. How to click on any element without any id or class name?
@jobinsjohn How did you sloved?
yeah, i want to know "How to click on any element without any id or class name" too ?
if where are some elements in li/ul, and these elements have no id or class, so how to click them ?
and another problem, some elements where attributes like 'data="xxx"' and 'data-info="zzz"', other attributes are all same, so how to click one (could i give ${date} or ${data-info} ?)
@wcccode The sample code for my solutions is as follows
page.evaluate(function()
{
var a = document.getElementById("ID_OF_YOUR_CONTROL"); // you can also use getElementByClassName
var e = document.createEvent('MouseEvents');
e.initMouseEvent('click', true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
a.dispatchEvent(e);
waitforload = true; // this is for some delay so that the page loads properly.
});
This is how i solved the problem
@andypeker I am doing my research on that. Will let you know as soon as i get a solution for it. You can also report the problem in the main section also.
Please post support question to the mailing-list.