-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FeatureRequest: _WD_ElementSelectAction() 'selectvalue' and 'selecttext' and 'selectindex' #168
Comments
@mlipok Some general thoughts in no particular order --
IIRC, _WD_ElementSelectAction was originally created to provide access to a Select element's details that weren't otherwise available. We should try to stick to that "mission" as we look at adding features. |
IMHO |
IMNSHO I disagree. 😄 HTMLSelectElement has many different PEMs and it would be unrealistic to expect Can you demonstrate where there is a demand for these additional features? |
Yeah I agree that all are not required in this UDF but the main:
take a look on
The only one I propose is to have adequte features in WD UDF |
This UDF already has a similar function (_WD_ElementOptionSelect), but it relies on the user providing the proper selector and it doesn't break down the individual modes. IMO, if more "select" options are going to be added, they should be implemented here and not it _WD_ElementSelectAction. |
I think that I trully do not understand why there are two separate functions for |
They deal with different element types, which is why there are two separate functions --
Therefore, code for selecting an Option element doesn't belong in _WD_ElementSelectAction. However, it would be appropriate to add code dealing with |
|
So you must to know which
Why not 'selecting' by performing search over all options on a previously located Select element ?
btw. |
Technically, it's a wrapper for locating (_WD_FindElement) and clicking (_WD_ElementAction) an element. Here's a link to the original discussion that spawned this function. Theoretically, we could rename this function to _WD_FindAndClickElement.
I think you are starting to wear me down. 😆 My concern is that the implementation needs to make sense to me. Currently we have I suggest that we add a single Obviously, input from others is welcome here too. 👍 |
Sorry for wearing you down. I can blame it on my poor English ;)
Now you answer to my question. Thanks.
If we add a single Thus I propos to specify 3 different command name which will lead to specific selection type (search and selection action), which will allow to add only one additional parameter which I call
Absolutely right. |
@mlipok Still hoping that you will suggest some other alternatives that don't involve adding even more parameters. Here are a few (not necessarily good ones 😉 ) to get you started --
|
Just start analyzing. Will test this first. |
Checked: Local $v_Result = _WD_ElementOptionSelect($sSession, $_WD_LOCATOR_ByCSSSelector, '#MainContentForm_ddlAdvStatus.form-control option[value="8"]')
Local $v_Result = _WD_ElementOptionSelect($sSession, $_WD_LOCATOR_ByXPath, '//select[@id="MainContentForm_ddlAdvStatus"]/option[@value="8"]')
Local $v_Result = _WD_ElementOptionSelect($sSession, $_WD_LOCATOR_ByXPath, '//select[@id="MainContentForm_ddlAdvStatus"]/option[contains(text(), "Wszystkie wpisy, w tym wykreślone")]') All this function works. So selecting by Value and by Text is possible with _WD_ElementOptionSelect() but this was not well documented. As to selecting by Index , my plan is to provide PR with this code concept: Case 'selectedindex'
$sScript = "arguments[0].selectedIndex = " & $sParameter
$sText = _WD_ExecuteScript($sSession, $sScript, __WD_JsonElement($sSelectElement), Default, $_WD_JSON_Value)
$iErr = @error
If $iErr = $_WD_ERROR_Success Then
If $sText = True Then
......
EndIf
EndIf What you think about ? |
How would you propose to document it further besides providing examples? I haven't looked into it, but you may be able to select by index using the same technique. If you get a chance, check it out and let me know what you find. |
As to the example, take a look here: Do you think that this could be or not provided in wd_demo.au3 or the examples topic/thread in the forum is right place, or should I add them to the WiKi ?
There is an implementation of this technique. |
For all occurance of: ; $sSelector - Value to find Proposal: ; $sSelector - String or expression related to chosed $sStrategy which should navigate to the specific element. for Proposal: ; Remarks .......: You can choose Option by Index, Value, Text by providing proper XPath or CSSSelector expression as a $sSelector parameter |
There are a few issues with this example --
IDK. I'm not sure that a separate demo is necessary. Maybe a reduced form of it could be incorporated into DemoElements. Maybe the wiki could have a separate page on CSS / xpath selectors with some examples. |
Lots of issues here IMO. Let's break it down into small chunks --
I'm not sure what this means or how it improves the user's understanding of the parameter's usage. Please explain to me how adding the word "expression" helps here.
"chosed" is the wrong word here. Maybe you wanted "chosen", "indicated", or something similar.
"navigate" is confusing here. I think of browser navigation unless you add something like "the HTML DOM" following the word navigate. |
XPath stirnigs are expressions So I was thinking that this will be correct to use this word. We could write it ; $sSelector - String, Xpath expression or CSS Selectors related to choosed $sStrategy which should navigate to the specific element. or simply ; $sSelector - String related to choosen $sStrategy which should navigate to the specific element. And after thinking about all yours other sugestion about corretness in using "English" (thanks) here is new proposal: ; $sSelector - string related to choosen $sStrategy that should indicate how the WebDriver should traverse through the HTML DOM to the specified element. |
Fixed , check the link again. |
What you think about my implementation this technique? |
So this also should be changed: ; Remarks .......: You can indicate specific <Option> element by Index, Value, Text by providing proper XPath or CSSSelector string as a $sSelector parameter |
s/b "chosen" 😄 But that still seems to "wordy" to me. I would prefer something more succinct such as --
To me, it's obvious that $sSelector needs to be in the format specificed in $sStrategy. However, this could be clarified in the remarks section if you think it necessary to state in the header. |
Again, I feel this is self-explanatory. It's simply how webdriver works. Maybe this would be better suited for a "getting started" section of the wiki? 🤷♂️ |
Please don't take this the wrong way, but I don't see anything "mind blowing" in that example. After all, you're just dynamically building CCS and xpath selectors, right? 🙂 |
Okay. Understood.
For me WiKi WD page is like a "getting started guide" especially: So I feel that we should not create sub page, or sub section for "getting started" |
I was just asking is that what you was thinking about, when you proposed to use this technique ? |
But maybe you meant to additionally show an example of simple concise code with comments? |
Ok. Maybe a different name then? Something like "Beginner's guide to Webdriver selectors"
FWIW, I don't think we need more source files at this stage.
Yes. My general thinking was that the UDF user needs to understand the various selectors; it isn't targeted at beginners, so we shouldn't need to provide separate functions for each selection type (id, name, etc) when a single function would suffice. Granted, we since added some functions like |
I was thinking about such example: #include "wd_helper.au3"
#include "wd_capabilities.au3"
_Example()
Func _Example()
# REMARK
# This is not functional script
# It only shows the concept how to use WebDriver UDF
; If you want to download/update dirver the next line should be uncommented
;~ _WD_UpdateDriver('chrome')
; specify used driver port parameters and other options
_WD_Option('Driver', 'chromedriver.exe')
_WD_Option('Port', 9515)
_WD_Option('DriverParams', '--verbose --log-path="' & @ScriptDir & '\chrome.log"')
; start the driver
_WD_Startup()
; create capabilites for session
_WD_CapabilitiesStartup()
_WD_CapabilitiesAdd('alwaysMatch', 'chrome')
_WD_CapabilitiesAdd('w3c', True)
_WD_CapabilitiesAdd('excludeSwitches', 'enable-automation')
Local $sCapabilities = _WD_CapabilitiesGet()
; create session with given Capabilities
Local $WD_SESSION = _WD_CreateSession($sCapabilities)
; navigate to some website
Local $sURL = '******'
_WD_Navigate($WD_SESSION, $sURL)
; wait for loading process ends
_WD_LoadWait($WD_SESSION, 1000)
#Region - do your's stuff
; for example find element
Local $sElement = _WD_FindElement($WD_SESSION, $_WD_LOCATOR_ByXPath, "*****")
; get text
Local $sText = _WD_ElementAction($WD_SESSION, $sElement, 'text')
ConsoleWrite($sText & @CRLF)
; or click the element
_WD_ElementAction($WD_SESSION, $sElement, 'click')
#EndRegion - do your's stuff
; on the end session should be deleted
_WD_DeleteSession($WD_SESSION)
; and driver should be closed
_WD_Shutdown()
EndFunc ;==>_Example |
Ok now I understood what you mean about "Getting Started" on WiKi. |
Maybe we can include something like this when we eventually get around to providing example code for the help file (see #133). For now, it will have to wait.
Yes, something that gave a basic overview of selectors, the differences between xpath & css, and perhaps provided links to some other recommended reading. |
SUMMARY:
Is this the only one thing which should be done as PR ? Do we have all other's things expalained in this ISSUE? |
I don't think so, as you've shown that this can be done with Maybe you meant to show the retrieval of selectedIndex instead? |
Exactly. |
After your's thumbs up, the last things to confirm here.
If so this issue can be closed. |
We discussed changes to $sSelector description and remarks. Did you plan to make those changes? |
Yes. |
I would not use this Remarks because this following ; Name ..........: _WD_ElementOptionSelect
.....
.....
; $sSelector - Indicates how the WebDriver should traverse through the HTML DOM to locate the desired element(s). Should point to <option> in element of type '<select>'
.....
..... |
As for now this is only a concept.
But what you think about ?
The text was updated successfully, but these errors were encountered: