Jump to content
Danp2

WebDriver UDF (W3C compliant version) - 09/17/2018

Recommended Posts

thuong12382
On 26/10/2018 at 1:45 AM, Danp2 said:

Hi @HJL,

I believe that your desired capabilities needs adjusted, as the binary option needs to include the executable name as well. FWIW, it didn't work In my brief testing when I used the FirefoxPortable.exe from Portableapps.com. However, I did get it to work by changing to the actual executable found in the App\Firefox64 subdirectory.

Dan

Hi Dan, i got the error : _WD_Startup ==> Invalid value: Location for Web Driver not set. this is my very short code: 

#include "wd_core.au3"
#include "wd_helper.au3"


Local $first, $ssession
;~ SetupChrome()
_WD_Startup()
$ssession = _WD_CreateSession($first)
_WD_Navigate($ssession,"")
_WD_Shutdown()

If i enable SetupChrome() then it get error undefined function. Sorry for my bad english and thank you so much for this UDF

Share this post


Link to post
Share on other sites
HJL

Hello Dan,

we were using FFau3 together with MozRepl and want to change to your UDF. We did not find a function to read content from a webpage element. Is it _WD_Action or _WD_ElementAction? How does it work?

Another question: does _WD_LoadWait return the same as _WD_FindElement?  If not, that would save code.

Have a nice weekend

Hans

Share this post


Link to post
Share on other sites
Danp2

Hi Hans,

You would use _WD_ElementAction to interact with an element. To retrieve its value, use 'text' as the value for  the $sCommand parameter.

3 hours ago, HJL said:

Another question: does _WD_LoadWait return the same as _WD_FindElement?  If not, that would save code.

This has been previously suggested for _WD_WaitElement. Is that what you mean? If not, please elaborate.

Share this post


Link to post
Share on other sites
pempemHY

Here is my radio buttons example:

My example radio buttons

Here is my simple code:

#include <wd_core.au3>
#include <wd_helper.au3>

Local $sDesiredCapabilities, $sSession

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

    $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"chromeOptions": {"w3c": true, "args":[' & """start-maximized""," & " ""disable-infobars""" & "" & '] }}}}'
 EndFunc   ;==>SetupChrome

SetupChrome()
_WD_Startup()

$sSession = _WD_CreateSession($sDesiredCapabilities)
_WD_Navigate($sSession, "https://www.w3schools.com/howto/tryit.asp?filename=tryhow_css_custom_radio")

$radio_4 = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//span[@class='checkmark']")
_WD_ElementAction($sSession, $radio_4, 'click')

_WD_Shutdown()

Can you help me to choose the radio button "Four". I have tried several times. I am new to this UDF, html and css. Thank you  <3

Screenshot (12).png

Share this post


Link to post
Share on other sites
Danp2

That site uses iframes, so you'll need to switch to the correct frame before you can locate the element with WD_FindElement. This can be done with _WD_Window or the helper function _WD_FrameEnter.

Check out the DemoFrames function in wd_demo.au3 for an example of using these functions.

  • Thanks 1

Share this post


Link to post
Share on other sites
pempemHY
On 10/11/2018 at 10:38 AM, Danp2 said:

That site uses iframes, so you'll need to switch to the correct frame before you can locate the element with WD_FindElement. This can be done with _WD_Window or the helper function _WD_FrameEnter.

Check out the DemoFrames function in wd_demo.au3 for an example of using these functions.

#include "wd_core.au3"
#include "wd_helper.au3"

Local Enum $eFireFox = 0, _
            $eChrome

Local $aDemoSuite[][2] = [["DemoTimeouts", False], ["DemoNavigation", False], ["DemoElements", False], ["DemoScript", False], ["DemoCookies", False], ["DemoAlerts", False],["DemoFrames", False], ["DemoActions", True]]

Local Const $_TestType = $eFireFox
Local $sDesiredCapabilities
Local $iIndex
Local $sSession

$_WD_DEBUG = $_WD_DEBUG_Info
SetupChrome()
_WD_Startup()
$sSession = _WD_CreateSession($sDesiredCapabilities)

_WD_Navigate($sSession, "https://www.w3schools.com/howto/tryit.asp?filename=tryhow_css_custom_radio")
ConsoleWrite("Frames=" & _WD_GetFrameCount($sSession) & @CRLF)
$sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//iframe[@id='iframeResult']")
_WD_FrameEnter($sSession, $sElement)
$text = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input")
_ArrayDisplay($text)
_WD_FrameLeave($sSession)
Sleep(30000)

_WD_DeleteSession($sSession)
_WD_Shutdown()

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

$sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"chromeOptions": {"w3c": true }}}}'
EndFunc

I have tried that example but i still don't know how to click that radio or reach to its ID . I am noob, can you tell clearlier?

Share this post


Link to post
Share on other sites
Danp2

That site is odd because it's using a custom radio button, but here's two ways to select the radio buttons --

#include "wd_core.au3"
#include "wd_helper.au3"

Local $sDesiredCapabilities
Local $iIndex
Local $sSession

$_WD_DEBUG = $_WD_DEBUG_Info

SetupChrome()

_WD_Startup()

$sSession = _WD_CreateSession($sDesiredCapabilities)

_WD_Navigate($sSession, "https://www.w3schools.com/howto/tryit.asp?filename=tryhow_css_custom_radio")
ConsoleWrite("Frames=" & _WD_GetFrameCount($sSession) & @CRLF)
$sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//iframe[@id='iframeResult']")
_WD_FrameEnter($sSession, $sElement)

; Method 1
$sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//label[3]/input")
_WD_ElementAction($sSession, $sElement, 'click')

Sleep(3000)

; Method 2
$aElements = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input", "", True)
;_ArrayDisplay($aElements)
_WD_ElementAction($sSession, $aElements[0], 'click')

Sleep(3000)

_WD_FrameLeave($sSession)
_WD_DeleteSession($sSession)
_WD_Shutdown()

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

    $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"chromeOptions": {"w3c": true }}}}'
EndFunc   ;==>SetupChrome

 

  • Thanks 1

Share this post


Link to post
Share on other sites
pempemHY

Thank you very much!!!

Share this post


Link to post
Share on other sites
HJL
On 9.11.2018 at 2:09 PM, Danp2 said:

Hi Hans,

You would use _WD_ElementAction to interact with an element. To retrieve its value, use 'text' as the value for  the $sCommand parameter.

This has been previously suggested for _WD_WaitElement. Is that what you mean? If not, please elaborate.

_WD_WaitElement is what I was looking for - perfect. Thanks for your help and for this UDF....

Share this post


Link to post
Share on other sites
pempemHY

Hi Dan, when i choose the $Command is 'action' in the function _WD_Action, can i control the page to scroll down? And how to do it?

Share this post


Link to post
Share on other sites
pempemHY
#include "wd_core.au3"
#include "wd_helper.au3"

Local $sDesiredCapabilities
Local $iIndex
Local $sSession

$_WD_DEBUG = $_WD_DEBUG_Info

SetupChrome()
_WD_Startup()
$sSession = _WD_CreateSession($sDesiredCapabilities)
_WD_Navigate($sSession, "https://www.youtube.com/")
Sleep(500)
_WD_Action($sSession, "actions", 'PageDown')
;ControlSend($handles, "", $controlID, '{PGDN}')
Sleep(20000)
_WD_DeleteSession($sSession)
_WD_Shutdown()

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

$sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"chromeOptions": {"w3c": true }}}}'
EndFunc

i try this with Youtube, key wasn't sent. Should i use ControlSend? Can i get controlID and handle of my session with this UDF?

Share this post


Link to post
Share on other sites
Danp2

In many cases, the scrolling will occur automatically once you interact with an element.

Why do you want to scroll the view? Again, what's your end goal?

 

  • Like 1

Share this post


Link to post
Share on other sites
pempemHY

Thank you, my problem was solved. Some elements at the bottom of the page (must use PageDown if you wan to see them) can't be interacted,.To solve this, i have set fullscreen chrome and it's OK.

Share this post


Link to post
Share on other sites
Danp2

@pempemHY I'd like to better understand the issue. Can you post an example, ideally with a publicly accessible website, where you can't interact with the element unless the browser is full screen?

Share this post


Link to post
Share on other sites
Acanis

Hey Danp2, thanks for creating this UDF :)

Didnt code some time, so maybe Iam just confused, but I cant get it to run^^...

  • I downloaded the UDFs JSON, WinHttp and this one. 
  • I unpacked the chromedriver in the same folder with wd_demo.
  • I started the demo with SciTE and changed: Local Const $_TestType = $eChrome
  • I start the demo (1 Chrome window is already open), and nothing happens with Chrome. All I can see, is that the driver is opening.

Iam using the newest Chrome version, every UDF and the driver are fresh downloaded, my AutoIt version is: 3.3.14.2

The demo is closing after a few seconds, my console says:

_WDStartup: OS: WIN_10 WIN32_NT 17134 
_WDStartup: AutoIt: 3.3.14.2
_WDStartup: WD.au3: 0.1.0.15
_WDStartup: Driver: chromedriver.exe
_WDStartup: Params: --log-path="C:\Users\Acanis\Downloads\Chromedriver\chrome.log"
_WDStartup: Port:   9515
__WD_Post: URL=HTTP://127.0.0.1:9515/session; $sData={"capabilities": {"alwaysMatch": {"chromeOptions": {"w3c": true }}}}
__WD_Post: StatusCode=400; ResponseText={"value":{"error":"invalid argument","message":"unrecognized capability: chromeOptions","stacktrace":"Backtrace:\n\tOrdinal0 [0x00CD4CB0+1526960]\n\tOrdinal0 [0x00C40C1D+920605]\n\tOrdinal0 [0x00BE5177+545143]\n\tOrdinal0 [0x00B65B94+23444]\n\tOrdinal0 [0x00B8CA63+182883]\n\tOrdinal0 [0x00B8D0B7+184503]\n\tOrdinal0 [0x00B8CEAD+183981]\n\tOrdinal0 [0x00B8B95B+178523]\n\tOrdinal0 [0x00B737A0+79776]\n\tOrdinal0 [0x00B74D5C+85340]\n\tOrdinal0 [0x00B74CB0+85168]\n\tGetHandleVerifier [0x00D8E1F1+584865]\n\tOrdinal0 [0x00CE3F63+1589091]\n\tOrdinal0 [0x00CE413D+1589565]\n\tOrdinal0 [0x00CE438A+1590154]\n\tOrdinal0 [0x00CDC937+1558839]\n\tOrdinal0 [0x00CE3DDF+1588703]\n\tOrdinal0 [0x00C5805E+1015902]\n\tOrdinal0 [0x00C643AB+1065899]\n\tOrdinal0 [0x00C644FA+1066234]\n\tOrdinal0 [0x00C63555+1062229]\n\tBaseThreadInitThunk [0x75718484+36]\n\tRtlValidSecurityDescriptor [0x77BE302C+284]\n\tRtlValidSecurityDescriptor [0x77BE2FFA+234]\n"}}
_WD_CreateSession: {"value":{"error":"invalid argument","message":"unrecognized capability: chromeOptions","stacktrace":"Backtrace:\n\tOrdinal0 [0x00CD4CB0+1526960]\n\tOrdinal0 [0x00C40C1D+920605]\n\tOrdinal0 [0x00BE5177+545143]\n\tOrdinal0 [0x00B65B94+23444]\n\tOrdinal0 [0x00B8CA63+182883]\n\tOrdinal0 [0x00B8D0B7+184503]\n\tOrdinal0 [0x00B8CEAD+183981]\n\tOrdinal0 [0x00B8B95B+178523]\n\tOrdinal0 [0x00B737A0+79776]\n\tOrdinal0 [0x00B74D5C+85340]\n\tOrdinal0 [0x00B74CB0+85168]\n\tGetHandleVerifier [0x00D8E1F1+584865]\n\tOrdinal0 [0x00CE3F63+1589091]\n\tOrdinal0 [0x00CE413D+1589565]\n\tOrdinal0 [0x00CE438A+1590154]\n\tOrdinal0 [0x00CDC937+1558839]\n\tOrdinal0 [0x00CE3DDF+1588703]\n\tOrdinal0 [0x00C5805E+1015902]\n\tOrdinal0 [0x00C643AB+1065899]\n\tOrdinal0 [0x00C644FA+1066234]\n\tOrdinal0 [0x00C63555+1062229]\n\tBaseThreadInitThunk [0x75718484+36]\n\tRtlValidSecurityDescriptor [0x77BE302C+284]\n\tRtlValidSecurityDescriptor [0x77BE2FFA+234]\n"}}
_WD_CreateSession ==> Webdriver Exception: unrecognized capability: chromeOptions
Bypass: DemoTimeouts
Bypass: DemoNavigation
Bypass: DemoElements
Bypass: DemoScript
Bypass: DemoCookies
Bypass: DemoAlerts
Bypass: DemoFrames
Running: DemoActions
__WD_Post: URL=HTTP://127.0.0.1:9515/session//url; $sData={"url":"http://google.com"}
__WD_Post: StatusCode=200; ResponseText={"sessionId":"","status":6,"value":{"message":"invalid session id\n  (Driver info: chromedriver=2.44.609538 (b655c5a60b0b544917107a59d4153d4bf78e1b90),platform=Windows NT 10.0.17134 x86_64)"}}
_WD_Navigate: {"sessionId":"","status":6,"value":{"message":"invalid session id\n  (Driver info: chromedriver=2.44.609538 (b655c5a60b0b544917107a59d4153d4bf78e1b90),platform=Windows NT 10.0.17134 x86_64)"}}
__WD_Post: URL=HTTP://127.0.0.1:9515/session//element; $sData={"using":"xpath","value":"//input[@id="lst-ib"]"}
__WD_Post: StatusCode=400; ResponseText=missing command parameters
_WD_FindElement: missing command parameters
_WD_FindElement ==> Webdriver Exception: HTTP status = 400
$sElement = 
$sAction = {"actions":[{"id":"default mouse","type":"pointer","parameters":{"pointerType":"mouse"},"actions":[{"duration":100,"x":0,"y":0,"type":"pointerMove","origin":{"ELEMENT":"","element-6066-11e4-a52e-4f735466cecf":""}},{"button":2,"type":"pointerDown"},{"button":2,"type":"pointerUp"}]}]}
__WD_Post: URL=HTTP://127.0.0.1:9515/session//actions; $sData={"actions":[{"id":"default mouse","type":"pointer","parameters":{"pointerType":"mouse"},"actions":[{"duration":100,"x":0,"y":0,"type":"pointerMove","origin":{"ELEMENT":"","element-6066-11e4-a52e-4f735466cecf":""}},{"button":2,"type":"pointerDown"},{"button":2,"type":"pointerUp"}]}]}
__WD_Post: StatusCode=200; ResponseText={"sessionId":"","status":6,"value":{"message":"invalid session id\n  (Driver info: chromedriver=2.44.609538 (b655c5a60b0b544917107a59d4153d4bf78e1b90),platform=Windows NT 10.0.17134 x86_64)"}}
_WD_Action: {"sessionId":"","status":6,"value":{"message":"invalid session id\n  (Driver info: chromedriver=2.44.609538 (b655c5a60b0b544917107a59d4153d4bf78e1b90),platform=Windows NT 10.0.17134 x86_64)"}}
__WD_Delete: URL=HTTP://127.0.0.1:9515/session//actions
__WD_Delete: StatusCode=200; ResponseText={"sessionId":"","status":6,"value":{"message":"invalid session id\n  (Driver info: chromedriver=2.44.609538 (b655c5a60b0b544917107a59d4153d4bf78e1b90),platform=Windows NT 10.0.17134 x86_64)"}}
_WD_Action: {"sessionId":"","status":6,"value":{"message":"invalid session id\n  (Driver info: chromedriver=2.44.609538 (b655c5a60b0b544917107a59d4153d4bf78e1b90),platform=Windows NT 10.0.17134 x86_64)"}}
__WD_Delete: URL=HTTP://127.0.0.1:9515/session/
__WD_Delete: StatusCode=200; ResponseText={"sessionId":"","status":0,"value":null}
_WD_DeleteSession: {"sessionId":"","status":0,"value":null}
+>19:09:44 AutoIt3.exe ended.rc:0
+>19:09:44 AutoIt3Wrapper Finished.
>Exit code: 0    Time: 11.23

The log says:

Quote

[1542737373.914][INFO]: [c19acd60b4cea2210aa6468670f02ae6] COMMAND InitSession {
   "capabilities": {
      "alwaysMatch": {
         "chromeOptions": {
            "w3c": true
         }
      }
   }
}
[1542737373.920][INFO]: [c19acd60b4cea2210aa6468670f02ae6] RESPONSE InitSession ERROR invalid argument: unrecognized capability: chromeOptions
 

Do you know, what Iam doing wrong? :)

 

Thanks

Aca

Share this post


Link to post
Share on other sites
Danp2

Ok... it looks like "chromeOptions" has been changed to "goog:chromeOptions".

I'll change this in wd_demo and will be releasing an update to the UDF soon.

Share this post


Link to post
Share on other sites
pempemHY
18 hours ago, Danp2 said:

@pempemHY I'd like to better understand the issue. Can you post an example, ideally with a publicly accessible website, where you can't interact with the element unless the browser is full screen?

#include <wd_core.au3>
#include <wd_helper.au3>
#include <MsgBoxConstants.au3>
#include <ButtonConstants.au3>
#include <Array.au3>
#include <DateTimeConstants.au3>
#include <EditConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>
#include <Windowsconstants.au3>
#include <String.au3>
#Region
Global $g_bPaused = False
Local $SD = False, $CD = False, $sDesiredCapabilities, $sSession
Local $bu_gio = 0, $_error = -1, $job_out = True, $dem = 'Running...'
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "Terminate")
#EndRegion
;=========================================================
Func TogglePause()
    $g_bPaused = Not $g_bPaused
    While $g_bPaused
        Sleep(2000)
   WEnd
EndFunc
;=========================================================
Func Terminate()
   MsgBox(0,'EXIT','Quit Auto',5)
    Exit
 EndFunc
;=========================================================
Func SetupChrome()
    _WD_Option('Driver', 'chromedriver.exe')
    _WD_Option('Port', 9515)
    _WD_Option('DriverParams', '--log-path="' & @ScriptDir & '\chrome.log"')

    $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"chromeOptions": {"w3c": true, "args":[' & """start-maximized""," & " ""disable-infobars""" & "" & '] }}}}'
 EndFunc   ;==>SetupChrome
;=========================================================
Func _ChromeSetInputValueByName($sSession,$Name,$Value)
 $sButton = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@name='"&$Name&"']")
 _WD_ElementAction($sSession,$sButton,'value', $Value)
EndFunc
;=========================================================
Local $time_per_job = 40000
ToolTip($dem, 0, 0)
;=====================Khởi động Chrome====================
SetupChrome()
_WD_Startup()

#Region ______Kh?i t?o session cho account______
$User = 'Nguyen.dat@fb.appen.com'
$pass = 'Nguyenbadat@'
$sSession = _WD_CreateSession($sDesiredCapabilities)
_WD_Navigate($sSession, "https://review.intern.facebook.com/intern/review")
$login1 = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//button[@id='u_0_a']")
_WD_ElementAction($sSession, $login1, 'click')
_ChromeSetInputValueByName($sSession,'email',$User)
$login2 = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//button[@type='submit']")
_WD_ElementAction($sSession, $login2, 'click')
_ChromeSetInputValueByName($sSession,'pass',$pass)
$login3 = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//button[@type='submit']")
_WD_ElementAction($sSession, $login3, 'click')
_WD_Navigate($sSession, 'https://review.intern.facebook.com/intern/review')
$button_go = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//a[@id='u_0_1w']")
_WD_ElementAction($sSession, $button_go, 'click')
;=============Load trang nếu ko có Button "just go"=============
While Not($button_go)
   Sleep(60000)
   _WD_Navigate($sSession, "refresh")
   $button_go = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//a[@id='u_0_1w']")
   _WD_ElementAction($sSession, $button_go, 'click')
WEnd
#EndRegion
;_____________________Khu là m việc_____________________
   $start1 = TimerInit()
   $dem = 0
   _WD_Window($sSession, 'fullscreen')      ;screen here
   Sleep(5000)
While True
   $start2 = TimerInit()
   ToolTip('SUM: '&$dem, 0, 0)
;#####################################################
   $div_element = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//div", "", True)
   $label_element = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//label", "", True)
   $button_element = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//button", "", True)
   Sleep(100)
   $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//div[@class = ' _2iek']") ;"Images" link at the upper right
   $message = _WD_ElementAction($sSession, $sElement, 'text') ;gets the text content of the node/element
   $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//span[@class = '_3-9a  _2ieq']") ;"Images" link at the upper right
   $loading = _WD_ElementAction($sSession, $sElement, 'text') ;gets the text content of the node/element
   If StringInStr($message,'no more jobs') Or StringInStr($loading,'ding') Then
      Sleep(60000)
      $bu_gio += 60000
      ContinueLoop
   ElseIf StringInStr($message,'ding') Or StringInStr($message,'expired') Then
      _WD_ElementAction($sSession, $button_element[4], 'click')
      ContinueLoop
   EndIf
;#####################################################
   $composer_box = _WD_ElementAction($sSession, $div_element[33], 'text')

   $like = StringInStr($composer_box,'like')
   If Not($like) Then $like = StringInStr($composer_box, 'thích')
   $cmt = StringInStr($composer_box, 'cmt')
   If Not($cmt) Then $cmt = StringInStr($composer_box, 'comment')
   If Not($cmt) Then $cmt = StringInStr($composer_box, 'bình lu?n')
   $share = StringInStr($composer_box, 'share ')
   If Not($share) Then $share = StringInStr($composer_box, 'chia s?')
   $link = StringInStr($composer_box, 'http')
   If Not($link) Then $link = StringInStr($composer_box, '.com')
   If Not($link) Then $link = StringInStr($composer_box, '.vn')
   If Not($link) Then $link = StringInStr($composer_box, '.net')
   If Not($link) Then $link = StringInStr($composer_box, 'www.')
   If Not($link) Then $link = StringInStr($composer_box, 'fb.')
   $vote = StringInStr($composer_box, 'vote')
   If Not($vote) Then $vote = StringInStr($composer_box, 'ch?n')
   $sdt = StringInStr($composer_box, ' 09')
   If Not($sdt) Then $sdt = StringInStr($composer_box, ' 1800')
   If Not($sdt) Then $sdt = StringInStr($composer_box, ' 1900')
   If Not($sdt) Then $sdt = StringInStr($composer_box, ' 02')
   If Not($sdt) Then $sdt = StringInStr($composer_box, ' 03')
   If Not($sdt) Then $sdt = StringInStr($composer_box, ' 05')
   If Not($sdt) Then $sdt = StringInStr($composer_box, ' 07')
   If Not($sdt) Then $sdt = StringInStr($composer_box, ' 08')
   $not_bait = Not($like Or $cmt Or $share Or $link Or $vote)
;#####################################################
   If $not_bait Then
      _WD_ElementAction($sSession, $label_element[14], 'click')
   Else
      If $like Then   _WD_ElementAction($sSession, $label_element[0], 'click')
      If $cmt Then    _WD_ElementAction($sSession, $label_element[2], 'click')
      If $share Then      _WD_ElementAction($sSession, $label_element[4], 'click')
      If $link Then   _WD_ElementAction($sSession, $label_element[8], 'click')
      If $vote Then   _WD_ElementAction($sSession, $label_element[12], 'click')
      Sleep(200)
      _WD_ElementAction($sSession, $label_element[16], 'click')
      Sleep(200)
      _WD_ElementAction($sSession, $label_element[32], 'click')
   EndIf
   Sleep(200)
   If $sdt Then
      _WD_ElementAction($sSession, $label_element[41], 'click')
   Else
      _WD_ElementAction($sSession, $label_element[43], 'click')
   EndIf
;#####################################################
;______�ợi đủ th�i gian yêu cầu để ấn Submit_______
   $end2 = TimerDiff($start2)
   If $CD Then
      $time_sleep = 0
   Else
      $time_sleep = $time_per_job - $end2
   EndIf
   If $SD Then
      $n = Round($time_sleep/5000) - 1
      For $i = 0 to $n
         MouseClick('left',0,0)
         Sleep(5000)
      Next
   Else
      Sleep($time_sleep)
   EndIf
   $submit = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//a[@class = '_3-8x _4jy0 _4jy4 _4jy1 _51sy selected _42ft']")
   _WD_ElementAction($sSession, $submit, 'click')
   If $submit Then
      $dem += 1
   Else
      _WD_ElementAction($sSession, $button_element[4], 'click')
   EndIf
;_______Kiểm tra xem là m đủ gi� hay chưa_______
   $time_all = 5*3600*1000
   $finish = TimerDiff($start1) - $bu_gio
   If $CD Then $time_all = 5*60*60*1000
   If $finish > $time_all Then
      Sleep(200)
      _WD_ElementAction($sSession, $button_element[2], 'click')
      Sleep(500)
      _WD_Shutdown()
      Sleep(500)
      If $SD Then
         Shutdown( 8)
      Else
         Exit
      EndIf
   EndIf
WEnd

Try this code! Then delete the line "_WD_Window($sSession, 'fullscreen')" and try it again . See the difference.

Share this post


Link to post
Share on other sites

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

  • Similar Content

    • Davidowicza
      By Davidowicza
      Hey guys,
      I am creating my very first script that automates a browser (I usually work with program installs and database automation) and have come across an issue that I am totally stumped on. I need to click an element that gives me a drop down list box but the Xpath to the element changes with every instance of chrome I start...
      I have tried selecting the class, rect, and path but no luck. It never finds the element. (I could be doing this wrong since I am not good at HTML)
      Element I need to select:
      This is the Xpath for the last 3 instances of chrome I have run the script with:
      //*[@id="highcharts-5bp9crq-8"]/svg/g[6]/g/rect //*[@id="highcharts-fiw9szv-8"]/svg/g[6]/g/rect //*[@id="highcharts-5szkmx8-8"]/svg/g[6]/g/rect As you can see the path changes every time.
      How I am trying to select the element:
      ;Check for box element _WD_WaitElement($sSession, $_WD_LOCATOR_ByXPath, "//*[@id='highcharts-5bp9crq-8']/svg/g[6]/g") MsgBox(0, "", "check for timeout") $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//*[@id='highcharts-5bp9crq-8']/svg/g[6]/g") _WD_ElementAction($sSession, $sElement, 'click') Maybe someone has come across this before and found a work around without using mouseclick()
      Thanks guys, hopefully I am just very overlooking something simple and can be pointed to the right solution.
      Side Note: I wish I could share the webpage entirety, but it has sensitive information with my agency that I cannot share. If you need more, just let me know and I will try and post as much as I can.
    • Danp2
      By Danp2
      This is the "General Help and Support" thread for the WebDriver UDF.
      The UDF itself can be downloaded here.
      So if you have any questions, suggestions or errors please post here.
    • daluu
      By daluu
      This is kind of already posted here:
      '?do=embed' frameborder='0' data-embedContent>>
      but wanted to note this in this forum of example scripts in case some people only look in this forum for examples and not the other forums with respect to AutoIt integration or relation to Selenium WebDriver.
      So, the example in summary is: you can use Selenium WebDriver API to do AutoIt GUI automation (the ControlXyz() and WinXyz() functons, along with mouse and "send keys" functions). Although I suppose that might be opposite or counter to what most examples here are about - using AutoIt to do or control other stuff rather than using other stuff to control/run AutoIt. But regardless, it is an example implementation of a different use case for AutoIt beyond the general AutoIt community, like those who also use Selenium WebDriver and/or need to integrate Selenium with AutoIt for remote deployment.
      https://github.com/daluu/AutoItDriverServer
      with specific demo examples here:
      https://github.com/daluu/AutoItDriverServer/blob/master/sample-code/CalculatorTest.java
      https://github.com/daluu/AutoItDriverServer/blob/master/sample-code/calculator.py
      https://github.com/daluu/AutoItDriverServer/blob/master/sample-code/SeleniumIntegrationTest.java
      https://github.com/daluu/AutoItDriverServer/blob/master/sample-code/SeleniumIntegrationWithAutoItDriver.py
    • TechCoder
      By TechCoder
      Below you will find both a new Marquee UDF (many W3C/HTML5 features and more) as well as a user-friendly program that both serves as an example script, as well as it will create the code for any particular marquee for you!  Enjoy!   ~~~~~~~~~~~~~~~~~  BACKGROUND on <marquee> ~~~~~~~~~~~~~~~~~ <marquee> has been classed as "non-standard" and "non-conforming" as an HTML element   (http://www.w3.org/wiki/HTML/Elements/marquee)  There is no promise that it will continue to be supported in the future, though it is obvious that many people have a need for this feature and it has remained in the major browsers for years.....   <marquee> was originally built into Internet Explorer only, now supported in other browsers, though some original features do not work in IE either - it is clearly trying to be phased out, though a 'replacement' of sorts is coming around, using HTML5 components, so I think it will never totally go away. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~   For a project I'm working on, I need a way to create a LOT of different marquees.  I thought it simpler to have a program create the code needed, and built the attached 'user interface' program using various references to the feature.   THE USER PROGRAM IS BACKWARD COMPATIBLE WITH THE EXISTING UDF FROM Melba23   I also needed some features that are not part of the UDF from Melba23 that are direct references to current (HTML5) recommendations from http://www.w3.org/TR/CSS2/, so I modified the current UDF to create the additional functions, which make the UDF more HTML5 compliant (some of the features I built in have no HTML5 component, existing functions were updated only where needed for the first release - perhaps someday the rest can be done, though no immediate plans)    *******************************************************************************************************************************    KNOWN ISSUES and/or LIMITATIONS within the user program   - Tip text NOT IMPLEMENTED (from _GUICtrlMarquee_SetDisplay $sTipTxt) - I had no use for it in my project, though it is not difficult to add if you need to   - border styles do not correspond to w3.org settings (not the program's fault...) This article (http://webdesign.about.com/od/beginningcss/a/aa091207.htm) states that IE does not support 'groove', 'ridge', 'inset' or 'outset' styles, yet does support 'dotted', 'dashed' and 'double'.   Testing has proven this is true for IE (11), however, in testing AutoIt (with the Marquee UDF), which I thought uses IE (?), it appears that just the OPPOSITE of this is true.  Another item for further testing/study.........   - 'Align' feature not working 100% on all fonts (not the program's fault! the initial version of <marquee> (designed for IE and copied to other browsers later) contained an element called 'align', which has long been obsolete in favor of css 'vertical-align', however, it is not a direct replacement  and does not work inside <marquee>.     Several alternatives were tried (including 'line-height' and even 'vspace', which may also soon be phased out) and nothing works 'perfectly' (search the web on font sizing and spacing - you will see this is extremely difficult).        This program works around these challenges in a 'best effort' way, using calculations and 'top-margin' (or vspace) spacing.        'Recommended' fonts (http://www.autoitscript.com/autoit3/docs/appendix/fonts.htm) will be set to 'center' or 'bottom' (within a pixel or 2), while other fonts may be off by several pixels (something in the font is different..).        If you need the other fonts, a bit of testing would give some offset numbers that could result in better display. (this is NOT on my list to do, though maybe someone would want to take that on???)   - You can create 'unreadable', 'unusable' and even 'UGLY' marquees (not the program's fault, either!) While a bit of effort was put into limiting things, there is no cross-checking to make sure your marquee will look 'nice'.  All parameters within the marquee feature have been tested to their max/min limits (and pushed well past the documented limits for speed and delay - you can make a  F A S T  or  S L O W  marquee well outside the published specs!) and set accordingly.   Any/all color scheme, font size, etc. can be used (no matter how horrible the outcome...) so have fun and create what you like!    *******************************************************************************************************************************   Additional recommendations from w3.org built into Marquee_W3C.au3 UDF   1. Border thickness (width) refered as "thin", "medium" and "thick" or <length> (any number - to infinity)      (http://www.w3.org/TR/CSS2/box.html#border-properties)     (http://www.w3schools.com/jsref/prop_style_borderwidth.asp) Marquee_W3C UDF allows any number as an entry, as well as the more 'friendly' named terms   2. Border Style is included in Marquee_W3C UDF (not in the current UDF, therefore, none of the settings in the user program do anything if you use the old UDF, so it is set to $GUI_DISABLE.)   3. use of PIXELS and EM for formatting text instead of POINTS      http://www.w3.org/TR/CSS2/fonts.html#font-size-props use <length> paramaters      http://www.w3.org/TR/CSS2/syndata.html#value-def-length with named length units (em, ex, cm, in, px, etc.)   POINTS are used in typsetting, while PIXELS, and EM are more correct methods of sizing fonts on modern monitors (one good article on this topic can be found at http://webdesign.about.com/cs/typemeasurements/a/aa042803a.htm )   NOTE: The user program is backward compatible with the UDF from Melba23 that uses POINTS and auto-sets the parameter with the chosen UDF.    
      Marquee_W3C.au3
      MarqueeMaker.au3
×