Jump to content

WebDriver UDF - Help & Support (II)


Danp2
 Share

Recommended Posts

5 minutes ago, nooneclose said:

_WD_Action($sSession, $wPsyCount, 'click')

Think you meant to use _WD_ElementAction here.

Quote

is this right for actions?

Earlier you stated that a mouse hover is necessary to open the menu. If that's accurate, then you shouldn't need the mouse click at all.

Try this, where $sElement is the element where you want the hover to occur --

$sAction = '{"actions":[{"id":"default mouse","type":"pointer","parameters":{"pointerType":"mouse"},"actions":[{"duration":100,"x":0,"y":0,"type":"pointerMove","origin":{"ELEMENT":"'
$sAction &= $sElement & '","' & $_WD_ELEMENT_ID & '":"' & $sElement & '"}}]}]}'
_WD_Action($sSession, "actions", $sAction)

 

Link to comment
Share on other sites

@Danp2 you were right. I got it to work with a combo of actions and element actions. Here is the working code.

Local Const $sElementSelector = "//a[@id='m74daaf83_ns_menu_AM55_HEADER_a']"
$sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, $sElementSelector)

; Opens the hidden menu 
$sAction = '{"actions":[{"id":"default mouse","type":"pointer","parameters":{"pointerType":"mouse"},"actions":[{"duration":100,"x":0,"y":0,"type":"pointerMove","origin":{"ELEMENT":"'

$sAction &= $sElement & '","' & $_WD_ELEMENT_ID & '":"' & $sElement & '"}},{"button":1,"type":"pointerDown"},{"button":1,"type":"pointerUp"}]}]}'
_WD_Action($sSession, "actions", $sAction)

; Clicks on the Physical Count
$wPsyCount = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//a[@id='m74daaf83_ns_menu_AM55_HEADER_sub_PHYSCNTADJ_OPTION_a']")
_WD_ElementAction($sSession, $wPsyCount, 'click')

Thank you very much for your help. 

Link to comment
Share on other sites

@Danp2 I am doing a click on a visible element (no hidden menus this time) but I am getting a weird error. 

I am getting a 'element click intercepted' error. Can you help me to understand why?

Here is the output:

__WD_Post: URL=HTTP://?/session/b2d962cdef97c735a0bbc05defe23d7f/element; $sData={"using":"xpath","value":"//span[@id='m6a7dfd2f_ttrow_[C:2]_ttitle-lb']"}
__WD_Post: StatusCode=200; ResponseText={"value":{"element-6066-11e4-a52e-4f735466cecf":"4c8643ac-48eb-4c4b-8f2c-d21770777daa"}}...
_WD_FindElement: {"value":{"element-6066-11e4-a52e-4f735466cecf":"4c8643ac-48eb-4c4b-8f2c-d21770777daa"}}
__WD_Post: URL=HTTP://?/session/b2d962cdef97c735a0bbc05defe23d7f/element/4c8643ac-48eb-4c4b-8f2c-d21770777daa/click; $sData={"id":"4c8643ac-48eb-4c4b-8f2c-d21770777daa"}
__WD_Post: StatusCode=400; ResponseText={"value":{"error":"element click intercepted","message":"element click intercepted: Element \u003Csp...
_WD_ElementAction: {"value":{"error":"element click intercepted","message":"element click intercepted: Element \u003Csp...
_WD_ElementAction ==> Element interaction issue: {"value":{"error":"element click intercepted","message":"element click intercepted: Element \u003Cspan id=\"m6a7dfd2f_ttrow_[C:2]_ttitle-lb\" align=\"left\" ctype=\"sortlabel\" tabindex=\"0\" ev=\"2\" targetid=\"m6a7dfd2f_ttrow_[C:2]_ttitle-lb\" mxevent=\"click\" class=\"text hcns   anchor\" style=\"padding:0px;padding-left:1px;margin:0px;cursor:pointer;\">...\u003C/span> is not clickable at point (319, 167). Other element would receive the click: \u003Cdiv id=\"wait\" width=\"100%\" height=\"100%\" class=\"wait\" style=\"position: absolute; top: 0px; left: 0px; height: 929px; width: 1920px; display: block; cursor: wait;\">...\u003C/div>\n  (Session info: chrome=83.0.4103.97)","stacktrace":"Backtrace:\n\tOrdinal0 [0x005D9563+2725219]\n\tOrdinal0 [0x004D8551+1672529]\n\tOrdinal0 [0x003C0359+525145]\n\tOrdinal0 [0x0035CADE+117470]\n\tOrdinal0 [0x0035BD1F+113951]\n\tOrdinal0 [0x0035AA27+109095]\n\tOrdinal0 [0x0035A232+107058]\n\tOrdinal0 [0x003543B1+82865]\n\tOrdinal0 [0x0036AA9D+174749]\n\tOrdinal0 [0x003541F6+82422]\n\tOrdinal0 [0x0036ACE1+175329]\n\tOrdinal0 [0x00373D7C+212348]\n\tOrdinal0 [0x0036A94B+174411]\n\tOrdinal0 [0x00352528+75048]\n\tOrdinal0 [0x003535A0+79264]\n\tOrdinal0 [0x00353539+79161]\n\tOrdinal0 [0x004ED607+1758727]\n\tGetHandleVerifier [0x006F6546+1050150]\n\tGetHandleVerifier [0x006F6291+1049457]\n\tGetHandleVerifier [0x007010D7+1094071]\n\tGetHandleVerifier [0x006F6B46+1051686]\n\tOrdinal0 [0x004E5B06+1727238]\n\tOrdinal0 [0x004EEB7B+1764219]\n\tOrdinal0 [0x004EECE3+1764579]\n\tOrdinal0 [0x00504C05+1854469]\n\tBaseThreadInitThunk [0x75A16359+25]\n\tRtlGetAppContainerNamedObjectPath [0x77E77C24+228]\n\tRtlGetAppContainerNamedObjectPath [0x77E77BF4+180]\n"}}
__WD_Post: URL=HTTP://?/session/b2d962cdef97c735a0bbc05defe23d7f/element; $sData={"using":"xpath","value":"//img[@id='m6a7dfd2f_ttrow_[C:2]_ttitle-si']"}
__WD_Post: StatusCode=200; ResponseText={"value":{"element-6066-11e4-a52e-4f735466cecf":"f983964d-260d-41ab-8d1e-2a6b8f9b0c66"}}...
_WD_FindElement: {"value":{"element-6066-11e4-a52e-4f735466cecf":"f983964d-260d-41ab-8d1e-2a6b8f9b0c66"}}

 

Link to comment
Share on other sites

@Danp2 Here is the HTML:

<th id="m6a7dfd2f_ttrow_[C:2]-c" tablecell="1" class="tc ">
    

<span id="m6a7dfd2f_ttrow_[C:2]_ttitle-lb" align="left" ctype="sortlabel" tabindex="0" ev="2" targetid="m6a7dfd2f_ttrow_[C:2]_ttitle-lb" mxevent="click" class="text hcns   anchor" style="padding: 0px 0px 0px 1px; margin: 0px; cursor: pointer;">Item</span>
<img id="m6a7dfd2f_ttrow_[C:2]_ttitle-si" tabindex="-1" border="0" aria-hidden="true" src="blank.gif" aria-live="polite" alt="Default Sort" width="0" height="11" align="absmiddle" style="margin:0px;" draggable="false">

        
</th>

Here is my code:

$sortItmNums = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//span[@id='m6a7dfd2f_ttrow_[C:2]_ttitle-lb']")
_WD_ElementAction($sSession, $sortItmNums, 'click')
Sleep(1500)

 

Edited by nooneclose
Link to comment
Share on other sites

Good Afternoon, 

sorry my english please , he is so so..... lol

I have a problem in autoit to send a double clique pelo actionelement.

Is possible send this command???  Thanks !!

Clayson

 

I maid this line and a fuction 

_ChromeSetActionByElement($sSession," //*[@id='tableEqpAtrib']/tbody/tr[1]/td","dblclick","dar clique duplo na equipe filtrada") ;SELECIONA ATRIBUIR NOTAS (ICONE CAMINHÃO)

 

 Func _ChromeSetActionByElement($sSession,$Element,$Action,$descracaocontrole)
    $sButton = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, $Element)
          If @error = $_WD_ERROR_Success Then

              _WD_ElementAction($sSession, $sButton,$Action) ; seleciona empresa no treegrid
          Else
     escrevelog("","","erro ao "&$descracaocontrole& @CRLF)
          Endif
 EndFunc

 

and i see it in log ...

__WD_Post: URL=HTTP://127.0.0.1:9515/session/b25be57d2244f258ed0b92afcd4c9a31/element/1c813b3d-56d4-48e0-9719-8d53a45f934e/dblclick; $sData={"id":"1c813b3d-56d4-48e0-9719-8d53a45f934e"}


__WD_Post: StatusCode=404; ResponseText={"value":{"error":"unknown command","message":"unknown command: unknown command: session/b25be57d224...


_WD_ElementAction: {"value":{"error":"unknown command","message":"unknown command: unknown command: session/b25be57d224...


_WD_ElementAction ==> Webdriver Exception: {"value":{"error":"unknown command","message":"unknown command: unknown command:

session/b25be57d2244f258ed0b92afcd4c9a31/element/1c813b3d-56d4-48e0-9719-8d53a45f934e/dblclick","stacktrace":"Backtrace:\n\tOrdinal0

[0x00DC9563+2725219]\n\tOrdinal0 [0x00CC8551+1672529]\n\tOrdinal0 [0x00BB0359+525145]\n\tOrdinal0 [0x00B5920E+168462]\n\tOrdinal0

[0x00B59074+168052]\n\tOrdinal0 [0x00B3235E+9054]\n\tOrdinal0 [0x00B327C6+10182]\n\tOrdinal0 [0x00B32E50+11856]\n\tOrdinal0

[0x00CDD607+1758727]\n\tGetHandleVerifier [0x00EE6546+1050150]\n\tGetHandleVerifier [0x00EE6291+1049457]\n\tGetHandleVerifier

[0x00EF10D7+1094071]\n\tGetHandleVerifier [0x00EE6B46+1051686]\n\tOrdinal0 [0x00CD5B06+1727238]\n\tOrdinal0 [0x00B32213+8723]\n\tOrdinal0

[0x00B31F20+7968]\n\tGetHandleVerifier [0x010BDC8C+2981228]\n\tBaseThreadInitThunk [0x75676359+25]\n\tRtlGetAppContainerNamedObjectPath

[0x77B47B74+228]\n\tRtlGetAppContainerNamedObjectPath [0x77B47B44+180]\n"}}

 

Link to comment
Share on other sites

@Clayson _WD_ElementAction doesn't support a doubleclick action, so that explains the error message you are receiving.

I haven't needed to perform a doubleclick, so not exactly sure how to advise you. You can try sending two single clicks back to back to see if that is sufficient. If not, you will probably need to use the advances "actions" option of _WD_Action.

Link to comment
Share on other sites

1 hour ago, Danp2 said:

@Clayson _WD_ElementAction doesn't support a doubleclick action, so that explains the error message you are receiving.

I haven't needed to perform a doubleclick, so not exactly sure how to advise you. You can try sending two single clicks back to back to see if that is sufficient. If not, you will probably need to use the advances "actions" option of _WD_Action.

Two clicks is not sufficient.
  Can you explain about advanced actions of _wd_action? Is possible double click in this options?

 there is no other option on my page , other than a doubleclick.

thanks!

 

 

Link to comment
Share on other sites

@Clayson You could try something like this --

$sAction = '{"actions":[{"id":"default mouse","type":"pointer","parameters":{"pointerType":"mouse"},"actions":[{"duration":100,"x":0,"y":0,"type":"pointerMove","origin":{"ELEMENT":"'
    $sAction &= $sButton & '","' & $_WD_ELEMENT_ID & '":"' & $sButton & '"}},{"button":0,"type":"pointerDown"},{"button":0,"type":"pointerUp"},{"button":0,"type":"pointerDown"},{"button":0,"type":"pointerUp"}]}]}'
_WD_Action($sSession, "actions", $sAction)

Completely untested, so YMMV. 😎

Link to comment
Share on other sites

Sorry to bother u sir, I have 2 Q, hope u can help me, thank you

image.png.1b193229ab934b4d6f199204e9861ffd.png

image.png.5fec66647b2c1fe320ceef4c1a407cd7.png

1. How can I get the how many edit_reason id and all edit_reason number (like get element)

as pic, No. 36 ~ No.37, I want to know Start is 36, Last is 37 and 2 edit_reason id element (dyamic number)

$element = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, '//*[@id="data_36_a"]')
_WD_FindElement(sSession, element, "click")

2. How can I get the element by "Text", like python find element .text("Radio B")

_WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, '//*[@type="radio"]', "Radio B")

 

Link to comment
Share on other sites

41 minutes ago, jimmy123j said:

How can I get the element by "Text", like python find element .text("Radio B")

This one is easy... just use contains --

_WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, '//*[@type="radio" and contains(text(), "Radio B")]')
45 minutes ago, jimmy123j said:

How can I get the how many edit_reason id and all edit_reason number (like get element)

Not sure that I understand your question. Maybe you need to retrieve all Div elements with that particular title and then process them to gather the details you are after. <shrug>

Link to comment
Share on other sites

On 6/12/2020 at 4:41 PM, Danp2 said:

@Clayson You could try something like this --

$sAction = '{"actions":[{"id":"default mouse","type":"pointer","parameters":{"pointerType":"mouse"},"actions":[{"duration":100,"x":0,"y":0,"type":"pointerMove","origin":{"ELEMENT":"'
    $sAction &= $sButton & '","' & $_WD_ELEMENT_ID & '":"' & $sButton & '"}},{"button":0,"type":"pointerDown"},{"button":0,"type":"pointerUp"},{"button":0,"type":"pointerDown"},{"button":0,"type":"pointerUp"}]}]}'
_WD_Action($sSession, "actions", $sAction)

Completely untested, so YMMV. 😎

  Danp2 , is functional. 😁

But , 😥

He keeps trying to do something while the script goes on and this error appears on the console

  _WD_Action: {"value":{"error":"javascript error","message":"javascript error: Failed to execute 'elementsFromPoint' on 'Document': The provided double value is non-finite.\n  (Session info: chrome=83.0.4103.97)","stacktrace":"Backtrace:\n\tOrdinal0 [0x00CF9563+2725219]\n\tOrdinal0 [0x00BF8551+1672529]\n\tOrdinal0 [0x00AE0359+525145]\n\tOrdinal0 [0x00AE20E5+532709]\n\tOrdinal0 [0x00AE1FD4+532436]\n\tOrdinal0 [0x00AE2190+532880]\n\tOrdinal0 [0x00A7C7D0+116688]\n\tOrdinal0 [0x00A7C29F+115359]\n\tOrdinal0 [0x00A9902A+233514]\n\tOrdinal0 [0x00A8AA9D+174749]\n\tOrdinal0 [0x00A93D7C+212348]\n\tOrdinal0 [0x00A8A94B+174411]\n\tOrdinal0 [0x00A72528+75048]\n\tOrdinal0 [0x00A735A0+79264]\n\tOrdinal0 [0x00A73539+79161]\n\tOrdinal0 [0x00C0D607+1758727]\n\tGetHandleVerifier [0x00E16546+1050150]\n\tGetHandleVerifier [0x00E16291+1049457]\n\tGetHandleVerifier [0x00E210D7+1094071]\n\tGetHandleVerifier [0x00E16B46+1051686]\n\tOrdinal0 [0x00C05B06+1727238]\n\tOrdinal0 [0x00C0EB7B+1764219]\n\tOrdinal0 [0x00C0ECE3+1764579]\n\tOrdinal0 [0x00C24C05+1854469]\n\tBaseThreadInitThunk [0x76E76359+25]\n\tRtlGetAppContainerNamedObjectPath [0x77AE7B74+228]\n\tRtlGetAppContainerNamedObjectPath [0x77AE7B44+180]\n"}}
_WD_Action ==> Webdriver Exception: HTTP status = 500

 

do you know what it can be? It works but I would like to resolve the error to make it available as a solution to the absence of doubleclik. It will help other people for sure, I almost stopped using it because of that, you rescued me kkkk !!!! 😁

 

thanks! 

Link to comment
Share on other sites

image.png.aa4223966151eafefadfdb95899b386d.png

Sorry for explain not clear, I mean I've No.1/3/4/10/11 item element want to click

and I wan't to use the For loop to get element and click, so I need to know the element reason_? (? = 1, 3, 4, 10, 11)

For $i = $Array[0] to $Array[4]
    $Element = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, '//*[@name="reason_"' & $i & '"]')
    _WD_FindElement(sSession, $Element, "click")
Next

something like get all element (name="reason_*")

image.png.97af8134b4577d57c83938d70b9991d3.png

Hope u can understand what I say

Sorry for bad english, and thanks ur reply !!!

Link to comment
Share on other sites

@jimmy123j Still not sure that I "get it". Using the example you posted, wouldn't that always click the "Radio A" instance for the element with the matching @name?

Maybe this will help --

$aElements = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//div[contains(@id, 'edit_reason_']", '', True)

If @error = $_WD_ERROR_Success Then
    For $sElement In $aElements
        ConsoleWrite(_WD_ElementAction($sSession, $sElement, 'attribute', 'id') & @crlf)
    Next
EndIf

Completely untested, but hopefully will give you an idea of what you can do.

Link to comment
Share on other sites

2 hours ago, Danp2 said:

@Clayson Sorry but I don't understand. Is that error a result of running the above code or something else? It would have provided better context if you had included some additional log entries (such as the prior __WD_Post).

In fact it was reassembling with the previous command, I put a time interval and solved it, but it is slow in relation to the click. I'm not complaining solved the problem but it didn't stay as an existing command like click for example. Is there anything that can be done to improve this performance? 

There will be many of these in a loop and in the end it would make a big difference in the overall performance.

thank's

Link to comment
Share on other sites

@Clayson Please post your revised code so that I can see your changes.

FWIW, I'm in the process of writing the function _WD_ElementActionEx, which will allow you to do things like this more easily. Right now, I have coding for these actions: hover, dblclick, and rgtclick. I'll add more as I think of them or receive suggestions.

Link to comment
Share on other sites

  • Jos locked this topic
Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...