Jump to content

WebDriver UDF - Help & Support (II)


Danp2
 Share

Recommended Posts

15 minutes ago, Retaki said:

why i need to look at _WD_WaitElement? what did you notice in my code? is the Wait Element doing the same am doing in the code i posted?

Yes, which you would have known if you looked at the function as suggested. 😋

17 minutes ago, Retaki said:

In this example there is a pop is already displayed, I can easily access it using the getElement function but how i can check if its already displayed or not?

You could try --

$lIsVisible = _WD_ElementAction($sSession, $sElement, 'displayed')

This is what I used in _WD_WaitElement when checking for an element's visibility.

Link to comment
Share on other sites

I'm new AutoIt (& Windows API). I've searched this topic & around forums, but I still don't quite understand the basic uses.

Where can I find instructions for finding out what each 'code' means?

Example:

$sElement = Object (Image/Video) or Text string
$sUrl = Website Link variable
$sSession = FireFox session?
$sNodeName = ?
$sDesiredCapabilities = ?


What does "Local" and "Global" mean?

This includes things like:

What does the small s after $ mean?

 

In other words, I'm trying to find out "What are these?" oppose to "How do I use it?"

 

Edited by Purity8
Added more info
Link to comment
Share on other sites

@Purity8 Mose of your questions can be answered by either --

  • Looking it up in the help file (ex: local vs global)
  • Reviewing the examples in wd_demo.au3

The items you posted above are just variables, so their contents / meaning could change depending on the context in which they are used.  Please review the above and then get back to us with any specific questions you may have.

Dan

P.S. Thanks to the Admin for moving this to the support thread!

Link to comment
Share on other sites

@Purity8 another good source for AutoIt-related information is the AutoIt Wiki.  For instance, answers to your specific questions, in your previous post, can be found in the Wiki's Best Coding Practices topic.

Link to comment
Share on other sites

My apologies for putting in the wrong section.

a) @Danp2, I'll go ahead & read all those *.au3 files then.

Quote

The items you posted above are just variables

I needed that confirmation, just wanted to make sure.

b) @TheXman, I had been to the wiki page, but wasn't able to find the specifics. Bingo!

c) @Nine, That's exactly what I was looking for!

 

Thanks everyone! 👍  👌

Edited by Purity8
Link to comment
Share on other sites

@Danp2, I do really facing a critical issue, i can select a value from a drop down box easily, but i cannot retrieve the current selected value, it always return nothing. 

<select class="form-control input-sm" id="dialog_settings_object_sensor_type" onchange="settingsObjectSensorType();">
                    <option value="acc">Ignition (ACC)</option>
                    <option value="di">Digital input</option>
                    <option value="do">Digital output</option>
                    <option value="fuel">Fuel level</option>
                    <option value="temperature">Temprature</option>
                    <option value="humidity">Humadity</option>
                    <option value="door">DOOR</option>
                    <option value="refrigerator">Refrigerator</option>

                    <option value="cust">Custom</option>
                    <option value="cust_weight">WEIGHT</option>
                    <option value="cust_low_high">Custom Low High</option>
                    <option value="water">Water</option>
                    <option value="rfid"> RFID </option>

                </select>

Am using _WD_ElementAction

Link to comment
Share on other sites

Well, i get the value  i want using a Javascript "_WD_ExecuteScript($sSession, "var x = document.getElementById('dialog_settings_object_sensor_type').value; alert(x);  ")".

I do not know how to get that variable to autoit variable. 

-----------

_WD_ExecuteScript($sSession, "var m = document.getElementById('dialog_settings_object_sensor_units'); var x = document.getElementById('dialog_settings_object_sensor_type').value; m.value = x; ")

I solved it by assigning the value to another text box then read that text box and know the value, but am not sure if this is the optimal solution. 

Edited by Retaki
Link to comment
Share on other sites

@Retaki Here's the way I would do it --

#include "wd_core.au3"
#include "wd_helper.au3"
Local $sDesiredCapabilities, $sSession, $mainElement

_WD_Option('Driver', 'chromedriver.exe')
_WD_Option('Port', 9515)
_WD_Option('DriverParams', '--log-path="' & @ScriptDir & '\chrome.log"')
_WD_Startup()

$sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true }}}}'
$sSession = _WD_CreateSession($sDesiredCapabilities)
_WD_Navigate($sSession, "https://mdn.mozillademos.org/en-US/docs/Web/HTML/Element/select$samples/Basic_select?revision=1617239")

Local $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//select")

If @error = $_WD_ERROR_Success Then
    $sJsonElement = '{"' & $_WD_ELEMENT_ID & '":"' & $sElement & '"}'
    $sResponse = _WD_ExecuteScript($sSession, "return arguments[0].value", $sJsonElement)
    $oJson = Json_Decode($sResponse)
    $sResult  = Json_Get($oJson, "[value]")

    ConsoleWrite($sResult & @CRLF)
EndIf

I'm guessing that this will be a common question, so will probably add a helper function for this.

Link to comment
Share on other sites

@Danp2 Sorry, I'm a little confused.

According to this site:
https://www.autoitscript.com/wiki/WebDriver#Requirements

I need a total of 4 files, but one of them does not have anything do download.

Json - check
WinHttp - check
WebDriver (Gecko) - check
independent WebDriver - missing?

https://github.com/Danp2/WebDriver/releases/tag/0.2.0.6
In the screenshot attached, only 2 Source Code files are shown, there's no download for "0.2.0.6.zip"?

I noticed the file wd_demo.au3 (that you asked me to read) is listed in there. I was so lost, thinking...something's definitely missing.

Now I know the reason.

No download.png

Edited by Purity8
Link to comment
Share on other sites

Hi Dan,

I have been searching for a while and didn't find anything: how to set the size and position of a window with 
 _WD_Window($sSession, 'rect', $sOption) ? 

I tried several forms f.e. like $sOption =  ' "x":84,"y":40,"width":1000,"height":700 ' but no luck.

 

Edited by HJL
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...