Troglodyne-Internet-Widgets / selenium-client-perl

WC3 Selenium client for Perl
6 stars 4 forks source link

Frame test in sanity.test appears not to be working quite right #5

Closed cgf1 closed 3 years ago

cgf1 commented 3 years ago

Output from "DEBUG=1 prove -vm -Ilib at/sanity.test":

Body: {"value":"#frame","using":"css selector"} 200 : {"value":{"element-6066-11e4-a52e-4f735466cecf":"f5b66c0a-2a2d-4e1a-9fa6-c0eced877c3a"}} Use of uninitialized value $Test::Builder::Level in subtraction (-) at /usr/share/perl5/Test/Fatal.pm line 109. POST http://127.0.0.1:35753/session/4e4367503beeb4ab63529ca48e47b9bd/frame Body: {"id":null} 200 : {"value":null}

You can see above that SwitchToFrame is being passed an undef element id which, for some reason, geckodriver lets through. I believe it's undef because the elementid field in the $frame structure doesn't exist until you "do something" with it like, e.g., $frame->GetAttribute(...); Not sure if that's a bug or not.

Also, should the test be using FrameId => rather than id => ?

teodesian commented 3 years ago

Use of uninitialized value $Test::Builder::Level in subtraction (-) at /usr/share/perl5/Test/Fatal.pm line 109.

Have reproduced, will investigate

should the test be using FrameId => rather than id => ?

Unlikely, see https://www.w3.org/TR/webdriver2/#switch-to-frame

It asks for id. WC3 webdriver also has a very bad habit of violently exploding on unrecognized parameters, so it's unlikely the script would have continued if this were true.

cgf1 commented 3 years ago

I saw that it wasn't part of the spec, but: DB<775> $selses->SwitchToFrame(FrameId => $frame->{elementid}) POST http://127.0.0.1:44311/session/5c6c5118-88dd-48c7-b4d2-07caa2483a48/frame Body: {"FrameId":"10b137ac-becf-4a94-987c-487c4962750b"} 200 : {"value":null} ^^^ That made me think it worked. But it doesn't seem to actually switch to the frame.

teodesian commented 3 years ago

hmm, I wonder if this is a similar cause as in #4... e.g. I've got a frame which is a child of some other frameset and I'm not correcting what to inject.

That said, I think this method is expected to return null. It would be more helpful to see the output of the subsequent command which failed. It may be we are simply not injecting the frame ID at all.

teodesian commented 3 years ago

In any case, I can (and probably should) add some sugar here such that you can just pass an element directly as the frame parameter.

teodesian commented 3 years ago

hmm, I did some extended testing, and it appears things just don't work as specified for iframes. It doesn't appear as though i'm doing anything different than say Selenium::Remote::Driver either so this is probably broken there too if so.

I will try things out in a frameset and report back results.

teodesian commented 3 years ago

Disregard prior (deleted) comment, I believe this is because the elementid is undefined until you execute another method on an element.

This is due to only doing this in the _request sub of Selenium::Subclass.

I should instead do this in the constructor. Fixing...

teodesian commented 3 years ago

disregard the disregard! I fixed elementid being undef, but alas, switching by element id indeed just seems broken in all the drivers.

Will update docs.

cgf1 commented 3 years ago

Here's my nonworking code: my $frame = $selses->FindElement(using => 'css selector', value => '#' . $command->{frame}); $frame->GetElementProperty(name => 'id'); $selses->SwitchToFrame(FrameId => $frame->{elementid});

The GetElementProperty call was so that elementid would be populated. Would it make sense to add an "elementid" method to retriever it maybe?

cgf1 commented 3 years ago

Btw, thanks for confirming that it's just broken. I was going crazy trying to figure out what i was doing wrong.

teodesian commented 3 years ago

going crazy

story of my life with the selenium drivers. None of their trackers are public, and their processes are opaque as a swamp.