Trying to access a login page using my script:
Using PhantomJS and Watir.
The issue with the login page is that the login textfields are within an iFrame:
<iframe class="hiFrame" data-reactid=".0.0.0.1.0.1.0.0.$frame" src="https://instagram.com/accounts/login/ajax/?targetOrigin=https%3A%2F%2Finstagram.com" scrolling="no" seamless="">
#document
<!DOCTYPE html>
<html class="hl-en not-logged-in " lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head></head>
<body class="LoginFormChrome ">
<div class="LoginFormPage" data-reactid=".0">
<form data-reactid=".0.0">
<p class="lfField" data-reactid=".0.0.0">
<label class="lfFieldLabel" data-reactid=".0.0.0.0"></label>
<input class="lfFieldInput" type="text" data-reactid=".0.0.0.1" value="" autocorrect="false" autocapitalize="false" maxlength="30" name="username"></input>
</p>
<p class="lfField" data-reactid=".0.0.1"></p>
<p class="lfActions" data-reactid=".0.0.2"></p>
</form>
</div>
<div id="fb-root" class=" fb_reset"></div>
</body>
</html>
</iframe>
Below is the Ruby code being used:
B.goto HOME_URL + LOGIN
sleep(5)
puts B.iframe(:class => "hiFrame").text_field(:name => "username").exists?
B.iframe(:class => "hiFrame").text_field(:name => "username").set USERNAME
B.iframe(:class => "hiFrame").text_field(:name => "password").set PW
#puts B.iframe(:class => "hiFrame").text_field(:name => "username").exists?
B.iframe(:class => "hiFrame").button.click
Everything works fine with Firefox browser, but encountering issues with PhantomJS.
B.iframe(:class => "hiFrame").text_field(:name => "username").exists?
This line is causing the script to stop. "true" is returned for:
B.iframe(:class => "hiFrame").exists?
How can I successfully log in to instagram with PhantomJS and Watir?
Thank you.