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.

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

Where Next?

Popular in Questions Top

shahryarjb
Hello, I get Persian date from my client and convert it to normal calendar like this: def jalali_string_to_miladi_english_number(persi...
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
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
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
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? https://hexdocs.pm/ecto/Ecto.Repo.h...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers' Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New

Other popular topics Top

Qqwy
Update: How to use the Blogs & Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3268 119930 1237
New
yurko
Here are few pieces of (common) Linux knowledge that we use for reasonably small one server apps. We use Ubuntu but this should work for ...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
AstonJ
You’re a programmer, so you don’t need spoon feeding with the conventional drivel about “this is an integer.” No. You need to know what’s...
New
malloryerik
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode. The solution seems to be, in a hyphena...
New
Jim
As a follow up to my earlier question: I have the code compiling and running but not getting a successful login from the rest server. ...
New
polypush135
As many of you may have realized by now (sorry for all the posts here) I’ve been working on a db problem where I’m trying to aggregate a ...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New

We're in Beta

About us Mission Statement