Jump to content

WebDriver UDF _WD_ElementActionEx() reports errors when trying to use command "MODIFIERCLICK"


Go to solution Solved by Danp2,

Recommended Posts

Running AutoIt v3.3.16.1.  au3WebDriver v1.3.1 downloaded from https://github.com/Danp2/au3WebDriver about a week or two ago.  Before posting this question, I went back there  and noticed that three files have been updated (wd_core.au3, wd_demo.au3, wd_helper.au3).  I have updated those three files, but the problem persists.  Using Firefox with geckodriver.

I am trying to click on a search button on a specific web page.  By default, this forces a new window to open with the content.  However, I want the content to open in a new tab, not in a new window.  If I hold down CONTROL key and then mouse click on the button, then it opens in a tab.  So I am trying to reproduce this in au3WebDriver code with _WD_ElementActionEx() using command "MODIFIERCLICK".  I tried a number of different things but I kept getting Invalid argument.  Here is an example:

_WD_ElementActionEx($sSession, $sElement_btnAssetLookup, "modifierclick", Default, Default, Default, Default, "\ue009")

And here is the error message:

_WD_ElementActionEx ==> Invalid argument [5] : Parameters:    Element=ab689017-29ea-4441-943e-621e3bb7d7e5    Command=modifierclick    XOffset=Default    YOffset=Default    Button=Default    HoldDelay=Default    Modifier=\ue009    ScrollView=Default

 

For awhile I was not sure if I was specifying the WebDriver key for CONTROL correctly.  So then I went back and decided to use command "click" just to make sure I had everything else specified correctly.  And that opens a new window as expected without errors.

_WD_ElementActionEx($sSession, $sElement_btnAssetLookup, "click", Default, Default, Default, Default, Default)
_WD_ElementActionEx ==> Success [0] : Parameters:    Element=ce6b46bf-431c-4de9-8602-f199a27881f1    Command=click    XOffset=Default    YOffset=Default    Button=Default    HoldDelay=Default    Modifier=Default    ScrollView=Default

I started thinking maybe you just cannot send CONTROL to the button using command "modifierclick".  So then I went and tried to use _WD_ElementActionEx() with command "modifierclick" using only defaults (according to the UDF, Default for $sModifier is "\uE008" (shift key).  SHIFT is not what I wanted, but I wanted to verify it would at least complete without an error, but it did not.  Here is what I tried:

_WD_ElementActionEx($sSession, $sElement_btnAssetLookup, "modifierclick", Default, Default, Default, Default, Default)

That gives a similar error message.

_WD_ElementActionEx ==> Invalid argument [5] : Parameters:    Element=9913ac04-2eed-4f20-871e-17efb09ca417    Command=modifierclick    XOffset=Default    YOffset=Default    Button=Default    HoldDelay=Default    Modifier=Default    ScrollView=Default

 

Anyone have any idea what is going on?

Thanks.

Link to comment
Share on other sites

Test case 1:

_WD_ElementActionEx($sSession, $sElement_btnAssetLookup, "click", Default, Default, Default, Default, Default)

still works as expected:

_WD_ElementActionEx ==> Success [0] : Parameters:    Element=5dcf7067-6c2f-4c1e-9d02-f00f85a7878e    Command=click    XOffset=Default    YOffset=Default    Button=Default    HoldDelay=Default    Modifier=Default    ScrollView=Default

 

Test case 2:

_WD_ElementActionEx($sSession, $sElement_btnAssetLookup, "modifierclick", Default, Default, Default, Default, Default)

now works as expected (before it gave _WD_ElementActionEx ==> Invalid argument [5] :):

_WD_ElementActionEx ==> Success [0] : Parameters:    Element=30faff28-a81d-4493-b8ac-0b6723b99cbd    Command=modifierclick    XOffset=Default    YOffset=Default    Button=Default    HoldDelay=Default    Modifier=Default    ScrollView=Default

 

Test case 3:

_WD_ElementActionEx($sSession, $sElement_btnAssetLookup, "modifierclick", Default, Default, Default, Default, "\ue009")

now works as expected (before it gave _WD_ElementActionEx ==> Invalid argument [5] :):

_WD_ElementActionEx ==> Success [0] : Parameters:    Element=f191c5d2-d6dd-492f-8023-8fd25dd4ae4d    Command=MODIFIERCLICK    XOffset=Default    YOffset=Default    Button=Default    HoldDelay=Default    Modifier=\ue009    ScrollView=Default

 

Additionally, I can confirm that using:

_WD_ElementActionEx($sSession, $sElement_btnAssetLookup, "modifierclick", Default, Default, Default, Default, "\ue009")

to CONTROL-CLICK the search button on that page causes the resulting page to be displayed in a new tab rather than the default behavior of opening in a new window.  So, this appears to have fixed the problem for me.

Thank you Danp2 for maintaining au3WebDriver in general and for correcting this.  Much appreciated!!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...