watzon / marionette

Selenium alternative for Crystal. Browser manipulation without the Java overhead.

Home Page:https://watzon.github.io/marionette/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error running at_exit handler

renich opened this issue · comments

When I ran the basic example with Firefox, it gives me this error:

Error running at_exit handler: Tried to run command without establishing a connection

Here's the source code:

require "marionette"

session = Marionette::WebDriver.create_session(:firefox)

# Navigate to crystal-lang.org
session.navigate("https://crystal-lang.org")

# Start an action chain and perform it
session.perform_actions do
  # Click the "INSTALL" link
  click ".main-actions a:nth-child(1)"
end

sleep 5
session.close

Also, the geckodriver version:

$ geckodriver --version
geckodriver 0.26.0 (e9783a644016 2019-10-10 13:38 +0000)

The source code of this program is available from
testing/geckodriver in https://hg.mozilla.org/mozilla-central.

This program is subject to the terms of the Mozilla Public License 2.0.
You can obtain a copy of the license at https://mozilla.org/MPL/2.0/.

Did it run first and then throw that? Or did it not even run?

It ran.

Ok, I just need to fix something with the at_exit handler then apparently. Right now it's just making sure the background processes close at exit.

OK. Thank you.

Idk why, but I can't reproduce. Can you delete your lib directory, your shard.lock and your ~/.cache/crystal directory, rerun shards install, and try again?

Also what version of Crystal are you using?

Here you go:

[renich@introdesk ~]$ crystal init app test
    create  /home/renich/test/.gitignore
    create  /home/renich/test/.editorconfig
    create  /home/renich/test/LICENSE
    create  /home/renich/test/README.md
    create  /home/renich/test/.travis.yml
    create  /home/renich/test/shard.yml
    create  /home/renich/test/src/test.cr
    create  /home/renich/test/spec/spec_helper.cr
    create  /home/renich/test/spec/test_spec.cr
Initialized empty Git repository in /home/renich/test/.git/
[renich@introdesk ~]$ cd test/
[renich@introdesk test]$ cat << EOF >> shard.yml 
> 
> dependencies:
>   marionette:
>     github: watzon/marionette
>     branch: master
> 
> EOF
[renich@introdesk test]$ rm -fr ~/.cache/crystal/
[renich@introdesk test]$ shards install
Resolving dependencies
Fetching https://github.com/watzon/marionette.git
Installing marionette (0.2.0 at 5a1ea2d)
Writing shard.lock
[renich@introdesk test]$ cat << 'EOF' > src/test.cr 
> require "marionette"
> 
> session = Marionette::WebDriver.create_session(:firefox)
> 
> # Navigate to crystal-lang.org
> session.navigate("https://crystal-lang.org")
> 
> # Start an action chain and perform it
> session.perform_actions do
>   # Click the "INSTALL" link
>   click ".main-actions a:nth-child(1)"
> end
> 
> sleep 5
> session.close
> 
> EOF
[renich@introdesk test]$ crystal run src/test.cr 
Error running at_exit handler: Tried to run command without establishing a connection

BTW, I have another instance of Firefox open.

Hmm I'll keep this open until I can figure out the issue. For me it doesn't even exit the process when using geckodriver for some reason. Still haven't been able to figure out why that is.

OK. Thanks for trying! My crystal version is 0.35.1

What OS? That could be helpful too.

Fedora 32.

Hah! Cool coincidence! Well, have a good time on your camping trip! ;D

@renich I know it's been a while, but is this still an issue? If you wouldn't mind testing with the most recent version on Crystal 1.0 I'd be grateful.

Err... checking...

What do you know? It works fine with Crystal v1.0.0! ;D

The run; pretty much the same that I did here: #21 (comment)

[renich@introdesk tmp]$ crystal init app test
cd test/
    create  /home/renich/tmp/test/.gitignore
    create  /home/renich/tmp/test/.editorconfig
    create  /home/renich/tmp/test/LICENSE
    create  /home/renich/tmp/test/README.md
    create  /home/renich/tmp/test/.travis.yml
    create  /home/renich/tmp/test/shard.yml
    create  /home/renich/tmp/test/src/test.cr
    create  /home/renich/tmp/test/spec/spec_helper.cr
    create  /home/renich/tmp/test/spec/test_spec.cr
Initialized empty Git repository in /home/renich/tmp/test/.git/
[renich@introdesk test]$ cat << EOF >> shard.yml 
^C
[renich@introdesk test]$ vim shard.yml 
[renich@introdesk test]$ rm -fr ~/.cache/crystal/
[renich@introdesk test]$ shards install
Resolving dependencies
Fetching https://github.com/watzon/marionette.git
Installing marionette (0.3.0 at 1544934)
Writing shard.lock
[renich@introdesk test]$ vim src/test.cr 
[renich@introdesk test]$ crystal run src/test.cr 
Error running at_exit handler: Tried to run command without establishing a connection
[renich@introdesk test]$ crystal version
Crystal 1.0.0 (2021-03-22)

LLVM: 10.0.0
Default target: x86_64-unknown-linux-gnu

Hmm so it's not working?

huh? It is. Maybe I pasted it wrong. It's working fine.

Tried again and I know why you say it isn't working. Because of this:

Error running at_exit handler: Tried to run command without establishing a connection

The browser opens, clicks on the first link under the first 'main-actions' class. It turns out it's not the "Install" link but the event link up there.

Other than that, it closes and, after the browser exits, it issues that error. I'm using This version of geckodriver:

geckodriver 0.29.1 (970ef713fe58 2021-04-08 23:34 +0200)

If I switch to :chrome, I get the same result without the error.

Hmm interesting. Well I'll keep this open just in case, but for now I have no idea what would be causing that error with geckodriver.

Let me know if you need anything from my side.

I'm going to close this for now. Let me know if it's still an issue and I'll reopen.