I'm writing some phantomjs code to scrape the site www.trivago.ie. First thing I have to do is to change the currency of the page. I've tried to do it with javascript or Jquery with no success.
I'm using the Developer console on the browser to test. According to the code I just have to click a li element, actually, on the console shows that the element has click event attached.
I've tried the following and nothing have worked. After clicking events nothing happens:
Jquery click event:
$("li#menu_locale").click()
Jquery trigger click event:
$("li#menu_locale").trigger("click")
Javascript creating event:
var a = document.getElementById("menu_locale");
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);
I've tried also clicking parents elements but doesn't work. It's an external page so I can't change the code.
The idea of clicking the element is to this element be filled with currency options:
<div class="dropdown-menu" id="js_toolbar_localization"></div>
Any help will be appreciated.
Thanks.
Just try
$("li#menu_locale em").trigger("click");
This will open the currency options