Selenium-Remote-Driver icon indicating copy to clipboard operation
Selenium-Remote-Driver copied to clipboard

I have a question.

Open yuki-kimoto opened this issue 4 years ago • 26 comments

I have a question.

Is there a place where I can ask questions about Selenium::Remote::Driver?

yuki-kimoto avatar Mar 01 '21 07:03 yuki-kimoto

yes

teodesian avatar Mar 01 '21 17:03 teodesian

Most people just ask questions here.

We don't have a chat or anything; lots of people just email me too. There's a Selenium::Remote::Driver mailing list on google groups: https://groups.google.com/g/selenium-remote-driver?pli=1 It's pretty dead, but I'm subscribed & post occasionally.

teodesian avatar Mar 01 '21 17:03 teodesian

Oh - One more thing: If you just want to chat, I have a matrix server. https://chat.troglodyne.net/ The "Troglodyne Open Source Support" public channel there would probably be where to ask things.

teodesian avatar Mar 01 '21 17:03 teodesian

I'm trying Selenium::Edge on Windows with Strawberry Perl.

I haven't been able to get it working yet.

I have a question.

Do Selenium::Edge support new Edge which is based on chromium?

yuki-kimoto avatar Mar 01 '21 23:03 yuki-kimoto

Not yet. That said it's probably pretty easy to add, given I support it in Selenium::Client already.

I'll make a subclass of Selenium::Chrome to make it work tomorrow. Thanks for the report.

teodesian avatar Mar 01 '21 23:03 teodesian

I will try it and want to join tests.

And I have some questions about new Edge.

  1. Can I use this Microsoft Edge WebDriver?

https://developer.microsoft.com/ja-jp/microsoft-edge/tools/webdriver/

  1. extra_capabilities key

I use "goog:chromeOptions" in case of Selenium::Chrome.

use Selenium::Chrome;
my $driver = Selenium::Chrome->new(
  extra_capabilities => {
    'goog:chromeOptions' => {
      args => ['headless', 'disable-gpu', 'window-size=1920,1080', 'no-sandbox' ]
    }
  }
);
$driver->get('http://www.google.com');
print $driver->get_title();
$driver->shutdown_binary();

In the case of New Edge Selenium, this will what name?

yuki-kimoto avatar Mar 02 '21 00:03 yuki-kimoto

  1. I don't see why not, that's what I use with Selenium::Client.
  2. the subclass I make should handle the extra_capabilities such that you don't have to even pass them.

I'm thinking of calling it MSEdge, since we already have Edge for legacy edge.

teodesian avatar Mar 02 '21 05:03 teodesian

I'm thinking of calling it MSEdge, since we already have Edge for legacy edge.

thank you!

yuki-kimoto avatar Mar 02 '21 21:03 yuki-kimoto

I don't see why not, that's what I use with Selenium::Client.

Maybe my English question is misread.

Do you say that Selenium::Client gets WebDriver automatically?

yuki-kimoto avatar Mar 02 '21 21:03 yuki-kimoto

the subclass I make should handle the extra_capabilities such that you don't have to even pass them.

I wanted to do headless execution on Linux with Selenium::Chrome.

A search of several sites found solutions in other programming languages.

This seemed to be a WebDriver-Dependent argument(goog:chromeOptions).

So in the case of the new Edge (MSEdge), I asked what this name would be.

I would be happy if there was a feature that didn't depend on this name.

yuki-kimoto avatar Mar 02 '21 21:03 yuki-kimoto

ah, I understand now.

The special capabilities name for edge is:

ms:EdgeOptions

teodesian avatar Mar 03 '21 01:03 teodesian

example of capabilities for edge to start headless:

my $caps = {
    AlwaysMatch => {
        browser => 'MicrosoftEdge',
        ms:EdgeOptions => {
            args => ['-headless'],
        }
    }
}
# This supposes you already have an instance of the Selenium JAR listening on port 4444
# with the proper options to find edgedriver set (-dWebDriver.edge.driver=$edgedriver_location_on_disk)
my $driver = Selenium::Remote::Driver->new_from_caps($caps);

I'll need to modify the direct driver class to make this "just work" if you do like so:

my $driver = Selenium::Edge->new();
...

This is because Selenium::Edge is built against the old non-chrome based Edge and I haven't updated it yet.

Which is because I'm trying to deprecate this module in favor of a better designed solution (Selenium::Client), but that's gonna take more time to have as user-friendly of an interface as S::R::D.

Nevertheless, if you want to try it out, Selenium::Client already supports the new edge, and is headless by default:

my $edge = Selenium::Client->new( browser => 'edge' );
my ($capabilities, $session) = $edge->NewSession();
$session->NavigateTo( url => 'https://google.com' );
...

teodesian avatar Mar 03 '21 01:03 teodesian

Updated Selenium::Edge in b92685715ff5a0b9433a09157fbef37b5d1a0c5f

teodesian avatar Mar 03 '21 01:03 teodesian

ms:EdgeOptions

thank you!

yuki-kimoto avatar Mar 03 '21 04:03 yuki-kimoto

Is Selenium::Client your new Selemium module?

Will what problem of Selenium::Remote::Driver Selenium::Client fix?

yuki-kimoto avatar Mar 03 '21 04:03 yuki-kimoto

Selenium::Client is my new selenium module, yes.

S::R::D is a big huge pain to maintain. It also doesn't support Selenium 4.0 ... which won't be a problem for you if you don't use the Selenium JAR file from seleniumhq.org to be your selenium server.

Selenium::Client does support Selenium 4.0, I figured that would be a good time to break a few things. The plan is to get a drop-in replacement for S::R::D, but I have a few things to do between here and there.

teodesian avatar Mar 03 '21 06:03 teodesian

Does Selenium::Client need a Jar file?

yuki-kimoto avatar Mar 04 '21 02:03 yuki-kimoto

Can you tell me a little more about the difference between Selenium::Client and Selenium::Remote::Driver?

yuki-kimoto avatar Mar 04 '21 02:03 yuki-kimoto

Any selenium client can use selenium servers, such as the java based one from SeleniumHQ ("the jar file").

Selenium::Client is capable of using the newest version of SeleniumHQ's server. Selenium::Remote::Driver is not. However, it can use any older version of said server, unlike Selenium::Client.

Both S::R::D and Selenium::Client can use the driver binaries themselves as their selenium servers (as they are all WC3 compliant selenium servers in and of themselves). The primary difference between the two is that you must use a specific subclass if you wish to automatically spawn an instance of the driver binaries (such as Selenium::Firefox) with S::R::D. With Selenium::Server, you can use the same class (Selenium::Server) which knows how to spawn every selenium server (including SeleniumHQ's, which S::R::D does not).

teodesian avatar Mar 04 '21 14:03 teodesian

Examples of the difference illustrated:

# Spawn instance of every browser with S::R::D
my @browsers = qw{Firefox Chrome Edge};
my @drivers_srd = map { "Selenium::$_"->new() } @browsers;
my @drivers_sc   = map { Selenium::Client->new( browser => $_ ) } @browsers;

# Connect to running selenium server somewhere
# Server must either be a driver binary or SeleniumHQ jar version < 4.0
my $driver = Selenium::Remote::Driver->new( remote_server_addr => $server );
# Server must either be a driver binary or SeleniumHQ jar version > 4.0
my $client  = Selenium::Client->new( host => $server );

# Auto-download and spawn a SeleniumHQ jar based server (only Selenium::Client knows how to do this)
my $client = Selenium::Client->new( driver => 'SeleniumHQ::Jar' );

teodesian avatar Mar 04 '21 15:03 teodesian

Aside from all those base features, the other primary difference is that the selenium method names themselves are different.

S::R::D's method names all correspond to the JSONWire selenium method names, and it uses positional arguments unique to this module.

Selenium::Client's method names all correspond to the WC3 selenium method names, and it's arguments are identical to those named in the specification document. This is because it uses a specification file auto-generated from the specification page itself to build all the underlying methods in the client.

teodesian avatar Mar 04 '21 15:03 teodesian

I write down what I understood.

  • Both use driver binary.
  • Selenium::Remote::Driver support SeleniumHQ jar version < 4.0
  • Selenium::Client support SeleniumHQ jar version >= 4.0
  • Selenium::Remote::Driver has JSONWire-like APIs
  • Selenium::Client has WC3 selenium method-like APIs
  • Selenium::Client don't have browser subclass.
  • Selenium::Client can automatically download SeleniumHQ::Jar and spawn the server.

Are these correct?

yuki-kimoto avatar Mar 04 '21 23:03 yuki-kimoto

yes

teodesian avatar Mar 05 '21 01:03 teodesian

I have some more questions.

  1. Which one do you recommend driver binary or SeleniumHQ::Jar?

  2. How dose Selemium::Client do the same as $driver->find_element(...)->click (Selemium::Remote::Driver)?

yuki-kimoto avatar Mar 05 '21 04:03 yuki-kimoto

  1. The JAR is essentially a proxy server for the browser drivers themselves, so you usually don't want to use it unless you want to use the "grid" functionality, which allows you to multiplex across multiple browsers (and servers!) transparently to scale testing. So if you don't need to massively scale your usage of selenium, it's probably not useful to you.

$session->FindElement( using => 'css selector', value => 'Edit' );

All methods available in Selenium::Client are detailed via the catalog() method, which returns a hash linking to the selenium specification' documentation for said method. That said, there is no 1-to-1 mapping of WC3 selenium methods to JSONWire selenium methods. Selenium::Remote::Driver has a number of polyfills to make up for this to be compatible with most modern selenium servers. To the point that it's more polyfills than client at this point.

teodesian avatar Mar 05 '21 05:03 teodesian

Thank you.

  1. In my little test, the driver binary looks good.

  2. I will dump catelog() data to understand WC3 selenium methods.

yuki-kimoto avatar Mar 05 '21 05:03 yuki-kimoto