Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trouble with login form #17

Open
dgoldie opened this issue Oct 29, 2014 · 5 comments
Open

Trouble with login form #17

dgoldie opened this issue Oct 29, 2014 · 5 comments
Assignees

Comments

@dgoldie
Copy link

dgoldie commented Oct 29, 2014

I'm trying to work with an external site to scrape data.
The data is unique per user, so I need to login.
When I click the submit button with tucotuco, the resulting page is wrong. I'm not logged in.
The form in question has a lot of hidden fields. Could that be an issue?

Here's a gist of an iex session.
https://gist.github.com/dgoldie/52fc48132aceff96e787
Am I doing something wrong?

thanks,
-doug.

To see the correct actions, manually:

The login form is at: "http://games.espn.go.com/ffl/signin"
I have a dummy account:
username: "cookiemonsters20"
password: "password1"

you'll know you're logged if:

  1. you see at the top "Jonathan, Active Insider"
  2. you see a section on the right labeled "MY TEAMS"
    with two teams listed, each with two links. One is "The Kerber League"
@stuart stuart self-assigned this Oct 30, 2014
@stuart
Copy link
Owner

stuart commented Oct 30, 2014

I get this:

Interactive Elixir (1.0.1) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> use TucoTuco.DSL
:ok
iex(2)> TucoTuco.start_session :test_browser, :tuco_test, :phantomjs
{:ok,
 %TucoTuco.SessionPool.SessionPoolState{app_root: nil,
  current_session: :tuco_test, max_retry_time: 2000, retry_delay: 50,
  use_retry: false}}
iex(3)> visit "http://games.espn.go.com/ffl/signin"
{:ok,
 %WebDriver.Protocol.Response{request: %WebDriver.Protocol.Request{body: "{\"url\":\"http://games.espn.go.com/ffl/signin\"}",
   headers: ["Content-Type": "application/json;charset=UTF-8",
    "Content-Length": 45], method: :POST,
   url: "http://localhost:51536/wd/hub/session/a331a610-5fca-11e4-a22e-43b41d396fc3/url"},
  session_id: "a331a610-5fca-11e4-a22e-43b41d396fc3", status: 0, value: %{}}}
iex(4)> fill_in "username", "cookiemonsters20"
{:error, "No field found with id, name or label specified"}
iex(5)> 

For me the username field is an input with no type attribute, so Finder.find :fillable_field, ... does not find it. Use Element.value/2 to fill it. eg Element.value input_element, "cookiemonsters20"

Also the password field was not getting filled: fixed in 0.7.1.

I'm not sure what exactly is happening in your trace. Can you run it with Firefox or Chrome and see if the fields are actually getting filled in correctly? (Or use save_screenshot with phantomjs.)

@dgoldie
Copy link
Author

dgoldie commented Oct 30, 2014

screenshots....cool, I'll try that
...may not be until Friday.

sorry, I forgot to mention I got it to work by removing @type='text' in finder.ex #line 50
MDN says type is an optional attribute for input; the default value is 'text' if its not present.
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Input
so, you might want a different test.

btw: after this change, I thought the password field was filled. Well, just using Finder and Element to get the value.

  def find :fillable_field, term do
    # case find :xpath, "//input[@type='text' and (@name='#{term}' or @id='#  {term}')] | \
    case find :xpath, "//input[@name='#{term}' or @id='#{term}'] | \
    //textarea[@name='#{term}' or @id='#{term}']" do
      nil     -> find :field_for_label, term
      element -> element
    end
  end

@stuart
Copy link
Owner

stuart commented Oct 30, 2014

You are right, the usual thing is to default to a text input. There's a bunch of other HTML5 input types too that could be considered fillable. I will have to change that.

You would get an error if the password field did not fill, so from the gist that looked like it worked.
I have it working in Firefox, Phantomjs is being temperamental.

@dgoldie
Copy link
Author

dgoldie commented Oct 31, 2014

Still doesn't work.
...though the screenshot show a nice page. just not logged in. :-)
updated to 0.7.1

also tried firefox, but it barfs (I did do the webdriver.firefox.install)

see errors:
https://gist.github.com/dgoldie/13564e431d303fb63c84

@stuart
Copy link
Owner

stuart commented Dec 21, 2015

Firefox was dying because the plugin was out of date. I'm a bit stuck with Firefox versions as there are different versions of the webdriver.xpi plugin from Selenium that work with various Firefox versions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants