Jump to content

WebDriver UDF - Help & Support (II)


Danp2
 Share

Recommended Posts

@Danp2Hello

Headless mode implemented by one simple option "--headless" adding in $sDesiredCapabilities
But for now, I need to control what is happening in the window.
So the question remains, is it possible to launch browsers in minimized mode?
And you did not answer, whether the functions still work: _WD_MoveMouseTo($sSession,$sElem), _WD_SetFocus($sSession,$sElem) ??

Link to comment
Share on other sites

1 hour ago, sarge said:

So the question remains, is it possible to launch browsers in minimized mode?

I previously suggested that you use the forum search feature or Google. What have you done to try to answer your own question?

Quote

And you did not answer, whether the functions still work: _WD_MoveMouseTo($sSession,$sElem), _WD_SetFocus($sSession,$sElem) ??

A couple of things I'd like to share with you about me --

  • I participate in these forums voluntarily because I enjoy it.
  • I subscribe to the "teach a man to fish" philosophy, so I try to point folks in the right direction and allowing them to solve their own issues

Some of our interactions haven't gone as well as I'd hoped. Not sure if there's a language barrier or some other issue. But the bottom line is that you need to start showing some effort to go allow with your questions.

I'd like to make a few requests of you --

  • When you post code, it should be "stand alone" where we can copy / paste it into Scite and then run it without further modification.
  • Don't just state that something doesn't work. Please include supporting details, like the Scite console output, so that we can better assist you.
  • If I've pointed you in a direction, show that you attempted to research / solve the issue on your own.

P.S. As far as the functions you've named above, these aren't part of the Webdriver UDF, so I have no way of knowing the answer to your question. My best guess would be Yes, they should still work on a minimized window.

 

Link to comment
Share on other sites

@Danp2 is it possible to attached WebDriver to an already opened Microsoft Edge page? 

I would like to make an edge bot that can "start" (attach it's self to) on a already opened webpage and retrieve data from certain fields and click on elements. 

Thank you for your time. 

Link to comment
Share on other sites

@nooneclose Check out _WD_Attach in wd_helper.au3

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.

Spoiler

My Humble Contributions:
Personal Function Documentation - A personal HelpFile for your functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts
UI-SimpleWrappers UDF - Use UI Automation more Simply-er
KeePass UDF - Automate KeePass, a password manager
InputBoxes - Simple Input boxes for various variable types

Link to comment
Share on other sites

Hi Dan, here is my next problem. I want to click a button that contains either ButtonGreen.png or ButtonRed.png or ButtonBlue.png. The XPath didn't help because the numbers 0, 1, 2 change. So I have to find the button with the png.s and then click it. I tried with 
$sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//*[@id="content-form:favorites:0:fav-image"]") and _WD_ElementAction($sSession,$sElement,"click") and similiar, but because the number between  :?:  (...favorites:0:....) is not always connected with the the name I did not succeed. So it must be a search with "src" and after that a click. Do you have an idea? I tried for hours and it didn't work. 

form id="content-form" name="content-form" method="post" action="/auth-portal/heavy-login/secure/linklist.xhtml" enctype="application/x-www-form-urlencoded">
<input type="hidden" name="content-form" value="content-form" />
<span id="content-form:growl"></span><script id="content-form:growl_s" type="text/javascript">$(function(){PrimeFaces.cw("Growl","widget_content_form_growl",{id:"content-form:growl",sticky:false,life:10000,escape:true,keepAlive:false,msgs:[]});});</script><div id="content-form:favorites" class="ui-datagrid ui-widget linklistDataGrid"><div id="content-form:favorites_content" class="ui-datagrid-content ui-widget-content ui-grid ui-grid-responsive"><div class="ui-g"><div class="ui-datagrid-column ui-g-12 ui-md-1">
                        
                        <div class="favListElement"><script type="text/javascript" src="/auth-portal/javax.faces.resource/jsf.js.xhtml?ln=javax.faces"></script><a id="content-form:favorites:0:extLink" href="#" onclick="mojarra.jsfcljs(document.getElementById('content-form'),{'content-form:favorites:0:extLink':'content-form:favorites:0:extLink'},'_blank');return false"><img id="content-form:favorites:0:fav-image" src="/auth-portal/javax.faces.resource/images/icons/vu/icon_ButtonGreen.png.xhtml?ln=heavy-login" alt="" style="width: 126px; height: 96px;" /><script id="content-form:favorites:0:j_idt94_s" type="text/javascript">$(function(){PrimeFaces.cw("Draggable","widget_content_form_favorites_0_j_idt94",{id:"content-form:favorites:0:j_idt94",target:"content-form:favorites:0:fav-image",cursor:"crosshair",containment:"#content-favorites",zIndex:9999,opacity:0.5,scope:"favorites",revert:"invalid",snap:true,snapTolerance:20,snapMode:"inner"});});</script><script id="content-form:favorites:0:j_idt95_s" type="text/javascript">$(function(){PrimeFaces.cw("Droppable","widget_content_form_favorites_0_j_idt95",{id:"content-form:favorites:0:j_idt95",target:"content-form:favorites:0:fav-image",hoverClass:"dropzoneHover",activeClass:"dropzoneActive",scope:"favorites",tolerance:"pointer",onDrop:handleDrop,behaviors:{drop:function(ext,event) {PrimeFaces.ab({s:"content-form:favorites:0:j_idt95",e:"drop",p:"content-form:favorites:0:j_idt95",u:"content-form:favorites"},ext);}}});});</script></a>
                        </div></div><div class="ui-datagrid-column ui-g-12 ui-md-1">
                        
                        <div class="favListElement"><a id="content-form:favorites:1:extLink" href="#" onclick="mojarra.jsfcljs(document.getElementById('content-form'),{'content-form:favorites:1:extLink':'content-form:favorites:1:extLink'},'_blank');return false"><img id="content-form:favorites:1:fav-image" src="/auth-portal/javax.faces.resource/images/icons/vu/icon_ButtonRed.png.xhtml?ln=heavy-login" alt="" style="width: 126px; height: 96px;" /><script id="content-form:favorites:1:j_idt94_s" type="text/javascript">$(function(){PrimeFaces.cw("Draggable","widget_content_form_favorites_1_j_idt94",{id:"content-form:favorites:1:j_idt94",target:"content-form:favorites:1:fav-image",cursor:"crosshair",containment:"#content-favorites",zIndex:9999,opacity:0.5,scope:"favorites",revert:"invalid",snap:true,snapTolerance:20,snapMode:"inner"});});</script><script id="content-form:favorites:1:j_idt95_s" type="text/javascript">$(function(){PrimeFaces.cw("Droppable","widget_content_form_favorites_1_j_idt95",{id:"content-form:favorites:1:j_idt95",target:"content-form:favorites:1:fav-image",hoverClass:"dropzoneHover",activeClass:"dropzoneActive",scope:"favorites",tolerance:"pointer",onDrop:handleDrop,behaviors:{drop:function(ext,event) {PrimeFaces.ab({s:"content-form:favorites:1:j_idt95",e:"drop",p:"content-form:favorites:1:j_idt95",u:"content-form:favorites"},ext);}}});});</script></a>
                        </div></div><div class="ui-datagrid-column ui-g-12 ui-md-1">
                        
                        <div class="favListElement"><a id="content-form:favorites:2:extLink" href="#" onclick="mojarra.jsfcljs(document.getElementById('content-form'),{'content-form:favorites:2:extLink':'content-form:favorites:2:extLink'},'_blank');return false"><img id="content-form:favorites:2:fav-image" src="/auth-portal/javax.faces.resource/images/icons/vu/icon_ButtonBlue.png.xhtml?ln=heavy-login" alt="" style="width: 126px; height: 96px;" /><script id="content-form:favorites:2:j_idt94_s" type="text/javascript">$(function(){PrimeFaces.cw("Draggable","widget_content_form_favorites_2_j_idt94",{id:"content-form:favorites:2:j_idt94",target:"content-form:favorites:2:fav-image",cursor:"crosshair",containment:"#content-favorites",zIndex:9999,opacity:0.5,scope:"favorites",revert:"invalid",snap:true,snapTolerance:20,snapMode:"inner"});});</script><script id="content-form:favorites:2:j_idt95_s" type="text/javascript">$(function(){PrimeFaces.cw("Droppable","widget_content_form_favorites_2_j_idt95",{id:"content-form:favorites:2:j_idt95",target:"content-form:favorites:2:fav-image",hoverClass:"dropzoneHover",activeClass:"dropzoneActive",scope:"favorites",tolerance:"pointer",onDrop:handleDrop,behaviors:{drop:function(ext,event) {PrimeFaces.ab({s:"content-form:favorites:2:j_idt95",e:"drop",p:"content-form:favorites:2:j_idt95",u:"content-form:favorites"},ext);}}});});</script></a>
                        </div></div><div class="ui-datagrid-column ui-g-12 ui-md-1">


 

Link to comment
Share on other sites

@Danp2 Can I get WebDriver to click on an element that is three elements deep? 

In the picture I attached I wanted to have my bot click on the PO_App link but it is buried in a unordered list. How would I go about clicking on it? 

I tried

$poApp = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//a[@id='m7f8f3e49_ns_menu_PURCHASE_MODULE_sub_changeapp_PO_a']")
_WD_ElementAction($sSession, $poApp, 'click')

but nothing happened. 

Screenshot (338).png

Edited by nooneclose
spelling mistakes
Link to comment
Share on other sites

53 minutes ago, nooneclose said:

I tried

$poApp = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//a[@id='m7f8f3e49_ns_menu_PURCHASE_MODULE_sub_changeapp_PO_a']")
_WD_ElementAction($sSession, $poApp, 'click')

but nothing happened.

That's not entirely accurate. If you have everything setup correct, then the Scite console would contain the results from your efforts. This information could help identity why this didn't work. Without it, we can only guess.

Link to comment
Share on other sites

@Danp2 I'm not sure I follow what you are saying. Are you saying that if I picked the right 'element' and 'tag' it would work despite if it is nested or not? 

I checked if it finds anything using consoleWrite and it does return this: f1f9bb69-f539-4fdb-b176-30b47f8c4aa0

Edited by nooneclose
new info
Link to comment
Share on other sites

@Danp2Hello,

9 hours ago, Danp2 said:
  • I participate in these forums voluntarily because I enjoy it.
  • I subscribe to the "teach a man to fish" philosophy, so I try to point folks in the right direction and allowing them to solve their own issues

I apologize for the incorrectly asked questions above.
I’ll try not to do that anymore.
Thank you for your work.

 

Link to comment
Share on other sites

@nooneclose That's not what I said. However, I believe that it is a true statement. 😃

If you run your script with $_WD_DEBUG = $_WD_DEBUG_Info, then the Scite console should be full of results. Sharing the pertinent portions of those results will help diagnose the issue.

I suspect you are encounter the error $_WD_ERROR_ElementIssue when you call _WD_ElementAction. This would likely be caused by the target element not being visible (you can't click on a hidden element).

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...