How to record a module to re-size Chrome browser window?

Class library usage, coding and language questions.
Fergal
Certified Professional
Certified Professional
Posts: 298
Joined: Tue Feb 18, 2014 2:14 pm
Location: Co Louth, Ireland
Contact:

How to record a module to re-size Chrome browser window?

Post by Fergal » Tue Jun 09, 2015 9:53 am

[Ranorex 5.3.2, Windows 7, Chrome 43.0.2357.81 m]

I want to re-size the Chrome browser window, to something like 640 x 960, before running a series of Test Cases. The options I have considered required the use of a third party website, Chrome extension or Google Dev Tools.

Is there a way to create a recorded module, that will re-size the Chrome browser window to 640 x 960, without the use of extensions or third party applications?

If it's not possible with a recorded module, can you please give me an indication as to how to do it with a code module?

If this is not possible for Chrome, perhaps you could please point me in the direction of how to do it for Firefox or IE.

Many thanks!

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3930
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: How to record a module to re-size Chrome browser window?

Post by odklizec » Tue Jun 09, 2015 1:06 pm

Hi,

Probably the easiest way (not involving 3rd party plugin or html page) is this code:

Code: Select all

repo.DOMName.Self.Resize(640,480);
Where the DOMName is a name of browser's DOM element stored in repository. Hope this helps?

PS:
Check also this post:
http://www.ranorex.com/blog/resize-window
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

Fergal
Certified Professional
Certified Professional
Posts: 298
Joined: Tue Feb 18, 2014 2:14 pm
Location: Co Louth, Ireland
Contact:

Re: How to record a module to re-size Chrome browser window?

Post by Fergal » Tue Jun 09, 2015 2:05 pm

Thanks very much odklizec! I have limited knowledge of C#, your code line is giving me the error below, which I don't understand:
'Ranorex.WebDocument' does not contain a definition for 'Resize' and no extension method 'Resize' accepting a first argument of type 'Ranorex.WebDocument' could be found (are you missing a using directive or an assembly reference?) (CS1061) - C:\0_Fergal\Ranorex\RanorexStudio Projects\[REMOVED]\Recordings\Common\Resize_Chrome_Browser_to_360_x_640.UserCode.cs:37,44
The code module using statements look like:
using Ranorex;
using Ranorex.Core;
using Ranorex.Core.Testing;
Do I need to add something else there?

Thanks again!

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3930
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: How to record a module to re-size Chrome browser window?

Post by odklizec » Tue Jun 09, 2015 2:12 pm

I'm afraid, I don't have a clue what could be wrong here? Could you please post the exact code you are using (screenshot of the UserCode.cs) and screenshot of repository containing the DOM element?
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3930
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: How to record a module to re-size Chrome browser window?

Post by odklizec » Tue Jun 09, 2015 2:30 pm

OK, The problem is most probably in the xpath of your DOM. The "Resize" method is not available to all elements! So you need to be careful about the xpath behind the element you want to resize!

Try to use the xpath ending with "form" element (like /form[@title~'Google Chrome']). To verify if Resize method is available to your repo element, try to drag&drop the element to recording and in the appeared menu expand InvokeAction.
Resize.png
Resize.png (20.6 KiB) Viewed 1428 times
If you don't see "Resize" method in the list of available actions, you need to use different path.
Another way of checking the method availability for a given element is using Rx intellisense. Once you start typing your code in source editor, Ranorex should offer you a list of available methods, variables, etc. (after each entered "."). Hope this helps?
Resize_2.png
Resize_2.png (10.82 KiB) Viewed 1428 times
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

Fergal
Certified Professional
Certified Professional
Posts: 298
Joined: Tue Feb 18, 2014 2:14 pm
Location: Co Louth, Ireland
Contact:

Re: How to record a module to re-size Chrome browser window?

Post by Fergal » Tue Jun 09, 2015 3:01 pm

Thanks a million odklizec, I have been working through it and that is exactly what the issue is - the Resize method is not available on my dom repository element. The XPath for the dom element I am using is simply:

dom[]

What should the XPath look like when trying to resize the Google Chrome browser window?

Thanks again!

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3930
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: How to record a module to re-size Chrome browser window?

Post by odklizec » Tue Jun 09, 2015 3:09 pm

Try this path...

Code: Select all

/form[@title~'Google Chrome']
or even simpler, this...

Code: Select all

/form
;)
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

Fergal
Certified Professional
Certified Professional
Posts: 298
Joined: Tue Feb 18, 2014 2:14 pm
Location: Co Louth, Ireland
Contact:

Re: How to record a module to re-size Chrome browser window?

Post by Fergal » Tue Jun 09, 2015 3:24 pm

Thanks odklizec, using "dom" where I should have been using "form" was the problem. It's working now and I have it in a recording module, using the Invoke > Resize option you have shown above.