Jump to content

Recommended Posts

Posted

Hi Danp2, i have resolved the problem by reading the consolelog .. to fix i have set the $options in format json in the function _WD_window (the function doesnt do the translation)

 

all is okay..just long time with the debug .. i have put my complete code in my post if some people have problems.  The objective was to click on a button display inside an iframe.

 

So is there an option to invalidate the debug in console?

Posted
  On 10/14/2020 at 4:37 PM, Frenchy said:

So is there an option to invalidate the debug in console?

Expand  

Not sure I understand. Do you mean to turn it off? If so, this is controlled by the value of $_WD_DEBUG. You can assign any of these to this variable  to control the log level --

$_WD_DEBUG_None   ; No logging to console
$_WD_DEBUG_Error  ; Error logging to console
$_WD_DEBUG_Info   ; Full logging to console

You can also set $_WD_CONSOLE to a valid filename and the log will be written to a file instead of the console.

Posted

Hi. I'm trying to get the links from a list (on Edge browser). Each list item has the following structure

<li class="activity folder modtype_folder " id="module-8407">
  <div>
    <div class="mod-indent-outer">
      <div class="mod-indent mod-indent-1">
      </div>
        <div>
          <div class="activityinstance">
            <a class="" onclick="" href="https://site.com/mod/folder/view.php?id=8407">
              <img src="https://site.com/theme/image.php/lambda/folder/1602062416/icon" class="iconlarge activityicon" alt=" " role="presentation" />
              <span class="instancename">Some text<span class="accesshide " > Folder</span></span>
            </a>
          </div>
        </div>
    </div>
  </div>
</li>

Full XPath:

/html/body/div[4]/div/div[2]/div/div/section/div/div/ul/li/div[3]/ul/li[42]/div/div/div[2]/div/a

XPath:

//*[@id="module-8407"]/div/div/div[2]/div/a

 

I have tried this in my code

$LINKS = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//a[@class='' and contains(@href,'folder')]", Default, True)

It returns an array with UUID formed values that are clickable items and each one points to the respectively link and so I can use on the them something like _WD_ElementAction($sSession, $LINKS[$i], 'click'), but I haven't a way to get the actual links. So far I can only get the text "Some text".

 

Posted

Hi danp2,

I want to automatically select 1 option in this sequence how, please guide me. I simulate the following:

please help me, i am new to udf web driver.

 

<div class="col-sm-8">
 <select name="PartnerGroup" class="form-control"><option value="">[Chọn nhóm khách hàng]</option>
<option value="1">Phổ thông</option>
<option value="2">Tài chính - Ngân hàng</option>
<option value="3">Ưu tiên (Y Tế, giáo dục)</option>
<option value="4">Thương mại điện tử</option>
<option value="5">Điện lực</option>
<option value="6">Nước</option>
<option value="7">Hành chính công</option>
<option value="8"> KH khu chế xuất, khu Công nghiệp</option>
<option value="9">Mạng Xã Hội</option></select>    </div>

Thank you verry much !!!

ok.png

Posted
  On 10/23/2020 at 4:01 AM, CYCho said:

@NguyenDuc, First you find the element ID of <select> tag with _WD_FindElement and then change the value of that element with _WD_ElementAction.

$sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//select[@name='PartnerGroup']")
_WD_ElementAction($sSession, $sElement, "value", "2") ; if you want to select the 2nd option

 

Expand  

I don't know why, but it doesn't seem to pick value 2

Posted (edited)
  On 10/23/2020 at 4:01 AM, CYCho said:

then change the value of that element with _WD_ElementAction.

Expand  

I think you meant...

; Name ..........: _WD_ElementOptionSelect
; Description ...: Find and click on an option from a Select element
; Syntax ........: _WD_ElementOptionSelect($sSession, $sStrategy, $sSelector[, $sStartElement = Default])

@NguyenDuc

_WD_ElementOptionSelect($gsSession, $_WD_LOCATOR_ByXPath, "//select[@name='PartnerGroup']/option[@value='1']")

 

Edited by TheXman
Posted

I'm not sure now.  :)  Maybe you could also use

; Name ..........: _WD_SetElementValue
; Description ...: Set value of designated element
; Syntax ........: _WD_SetElementValue($sSession, $sElement, $sValue)

 

Posted
  On 10/23/2020 at 5:16 AM, TheXman said:

I'm not sure now.  :)  Maybe you could also use

; Name ..........: _WD_SetElementValue
; Description ...: Set value of designated element
; Syntax ........: _WD_SetElementValue($sSession, $sElement, $sValue)

 

Expand  
$sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//select[@name='PartnerGroup']")
_WD_ElementOptionSelect($sSession, $sElement, "value", "2") ;

 

I did this but not correctly, but it doesn't seem to pick value 2

Posted
  On 10/23/2020 at 5:20 AM, NguyenDuc said:

_WD_ElementOptionSelect($sSession, $sElement, "value", "2") ;

Expand  

The correct syntax of _WD_ElementOptionSelect is _WD_ElementOptionSelect($sSession, $sStrategy, $sSelector[, $sStartElement = Default]) and this will click on the option box, not select an option item.

The following is the actual Select element I interact with and the code in my first post works well.
 

<select name="ctl00$ContentPlaceHolder1$ddlMobile1" id="ctl00_ContentPlaceHolder1_ddlMobile1">
    <option value="">선택</option>
    <option selected="selected" value="010">010</option>
    <option value="011">011</option>
    <option value="016">016</option>
    <option value="017">017</option>
    <option value="018">018</option>
    <option value="019">019</option>
</select>

You may want to confirm that the correct Select element was identified to begin with.

Posted
  On 10/23/2020 at 6:43 AM, CYCho said:

The correct syntax of _WD_ElementOptionSelect is _WD_ElementOptionSelect($sSession, $sStrategy, $sSelector[, $sStartElement = Default]) and this will click on the option box, not select an option item.

The following is the actual Select element I interact with and the code in my first post works well.
 

<select name="ctl00$ContentPlaceHolder1$ddlMobile1" id="ctl00_ContentPlaceHolder1_ddlMobile1">
    <option value="">선택</option>
    <option selected="selected" value="010">010</option>
    <option value="011">011</option>
    <option value="016">016</option>
    <option value="017">017</option>
    <option value="018">018</option>
    <option value="019">019</option>
</select>

You may want to confirm that the correct Select element was identified to begin with.

Expand  

Give me an example okay, bother you !!!!

  • Moderators
Posted

NguyenDuc,

Firstly, when you reply in future, please use the "Reply to this topic" button at the top of the thread or the "Reply to this topic" editor at the bottom rather than the "Quote" button - responders know what they wrote and it just pads the thread unnecessarily. Thanks in advance for your cooperation.

Secondly, I suggest you change your tone pretty quickly or you will find that you will not have any further responders. Your post above is quite beyond the pale.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

Posted

 

<button class="btn btn-primary" onclick="Brandname.saveAmount(3116)"><i class="fa fa-save"></i> Luu </button>

onclick="Brandname.saveAmount(3116)"

---> 3116 is a random number

$sButton = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//button[@onclick='Brandname.saveAmount(*)']")
    _WD_ElementAction($sSession, $sButton, 'Click')
    _WD_LoadWait($sSession, 200)

I tried like this but it is not correct. Please help me to solve it thanks a lot

 

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
×
×
  • Create New...