rodrigozc

rodrigozc

Select an option using Hound

Hello everyone,

I’m trying to automating navigation using Hound, but I’m having some troubles with select/option elements and how to interact with them.

For instance, I tried in different ways to select an option from the site “https://www.imovelweb.com.br/.

I tried the solution below but didn’t work.

https://github.com/HashNuke/hound/issues/72#issuecomment-178071219

I’m using the selenium driver with the chrome browser.

$ brew install selenium-server-standalone
$ selenium-server -port 4444
use Mix.Config

config :hound,
  driver: "selenium",
  browser: "chrome"

I tried to select in the following ways:

def search() do
    Hound.start_session()

    navigate_to(@url)

    find_element(:css, "#operationType option[value='1']")
    |> click

    #take_screenshot()

  rescue
    e ->
      IO.inspect(e)
      :notfound
  after
    Hound.end_session
  end

Error

%RuntimeError{
  message: "element not interactable: Element is not currently visible and may not be manipulated\n  (Session info: chrome=79.0.3945.88)\nBuild info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'\nSystem info: host: 'Rodrigos-MacBook-Pro.local', ip: '2804:14c:4a:9f9d:1591:2820:1fe7:d763', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.15.2', java.version: '1.8.0_131'\nDriver info: driver.version: unknown"
}
def search() do
    Hound.start_session()

    navigate_to(@url)

    find_element(:css, "#operationType")
    |> find_within_element(:css, "option[value='1']")
    |> click

    #take_screenshot()

  rescue
    e ->
      IO.inspect(e)
      :notfound
  after
    Hound.end_session
  end

Error

%RuntimeError{
  message: "element not interactable: Element is not currently visible and may not be manipulated\n  (Session info: chrome=79.0.3945.88)\nBuild info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'\nSystem info: host: 'Rodrigos-MacBook-Pro.local', ip: '2804:14c:4a:9f9d:1591:2820:1fe7:d763', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.15.2', java.version: '1.8.0_131'\nDriver info: driver.version: unknown"
}

I was wondering if I have to click on the select element before to show the options and then click on the chosen option, but when I tried to click on the select element I got another error.

def search() do
    Hound.start_session()

    navigate_to(@url)

    find_element(:css, "#operationType")
    |> click

    #take_screenshot()

  rescue
    e ->
      IO.inspect(e)
      :notfound
  after
    Hound.end_session
  end

Error

%RuntimeError{
  message: "element not interactable\n  (Session info: chrome=79.0.3945.88)\nBuild info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'\nSystem info: host: 'Rodrigos-MacBook-Pro.local', ip: '2804:14c:4a:9f9d:1591:2820:1fe7:d763', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.15.2', java.version: '1.8.0_131'\nDriver info: driver.version: unknown"
}

Thanks!

First Post!

wolfiton

wolfiton

I don’t see this in your code

use Hound.Helpers
hound_session()

This is what I am using to test by following this book https://shankardevy.com/phoenix-inside-out-mpf/ . But it uses phantomjs

Also if you use Linux install phantomjs like this Problem with acceptance test in hound not starting server on port 4001

Update found this in my tests, it might be similar with what you need:

find_element(:css, "#registration_residence_area option[value='Area 1']")
    |> click

Last Post!

wolfiton

wolfiton

OK then how about writing your select like this:

<%= select f, :category_id, Enum.map(@categories, &{&1.name, &1.id}), prompt: "Choose a category" %>

If this doesn’t work either then try to create a minimal example only with a slect and test hound on that to see if that works.
If it does then you most certenly have a problem in your actual code or a bug.

Where Next?

Popular in Questions Top

nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New

Other popular topics Top

nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
985 44532 311
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New

We're in Beta

About us Mission Statement