0

I am using Selenium 2.35.0 to test a Chromium based browser. I am using Chrome driver version 2.43.600233 and set my application name to Chrome and version to 2.43.600233 as recommended in
https://forum.qt.io/topic/96202/unrecognized-chrome-version-when-using-selenium-python-bindings-and-chromedriver

"I had the same problem, and a way to hack it is to set your QT applicationName and applicationVersion to "Chrome" and "69.0.3497.128". "

Everything then worked fine. I only ran to an issue when I tried maximizing,minimizing, changing window size of my window using

driver.manage().window().maximize(); 
driver.manage().window().setSize(d);

I ran to this error

{"code":-32601,"message":"'Browser.getWindowForTarget' wasn't found"}.

When I searched for that error,I found this question

Сhromedriver: how to add support of Chromium-based browsers

The answers mentions

I warn you in advance that you should not use the window_size parameter, since Chromium does not support it, otherwise we will encounter an error: [Facebook\WebDriver\Exception\UnknownServerException] unknown error: unhandled inspector error: {"code":-32601,"message":"'Browser.getWindowForTarget' wasn't found"}.

Is there any hack to get over that. I need to test my browser when I do any window resizing.

Thanks a lot in advance.

Merolla
  • 315
  • 2
  • 10

2 Answers2

0

I can tell you that on all recent Chrome versions (going back years), with up-to-date Chromedriver, in C#, setting driver.Manage().Window.Size works fine for me. But, I'm unfamiliar with setting app names and versions like you're doing. Does it work if you don't call maximize() first?

Conrad Albrecht
  • 1,976
  • 2
  • 15
  • 19
  • If I don't set the application name and version I get this exception Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: unrecognized Chrome version: xxxbrowser/.xxxbrowser is the Chromium based browser that am using. – Merolla Jul 07 '20 at 15:59
  • I should've mentioned that when I said "it works for me", that's with actual Chrome on Windows. I don't know what "Chromium based browser" or OS you're testing on. – Conrad Albrecht Jul 07 '20 at 19:39
0

I did the resizing using xdotool http://manpages.ubuntu.com/manpages/trusty/man1/xdotool.1.html. In my java code I have this function

public void xdoWindowResize(String width,String height)
{
    String  title= driver.getTitle();
    try{
    ProcessBuilder pb = new ProcessBuilder("./resize.sh", title,width,height);
    Process p = pb.start();
    }
    catch (Exception e) {System.out.println(e);}
}

and resize.sh

#!/bin/sh
my_id=$(xdotool search --name "$1")
xdotool windowsize $my_id $2 $3
Merolla
  • 315
  • 2
  • 10