Jump to content

Recommended Posts

Posted
45 minutes ago, Nine said:

Not sure how long it is going to work.  You may need to adapt it to new (or old) version. 

WOW!

If it works for while, is good enough.

Thanks!

Posted

Hi, im trying to interact with binance.com, i would like to press a button and retrieve a table, but it seems cant do any of that, looked into the demos, but couldn't figure it out.

What im trying to do: get into https://www.binance.com/en/markets, press BTC Markets, and get all the values from the table.

What i tried so far:

#include "wd_core.au3"
#include "wd_helper.au3"
#include <GuiComboBoxEx.au3>
#include <GUIConstantsEx.au3>
#include <ButtonConstants.au3>
#include <WindowsConstants.au3>

Local $sDesiredCapabilities, $iIndex, $sSession
SetupGecko()

_WD_Startup()
$sSession = _WD_CreateSession($sDesiredCapabilities)

_WD_Navigate($sSession, "https://www.binance.com/en/markets")
_WD_LoadWait($sSession, Default, Default, Default)
; Locate a single element
$sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@class='css-1vs0no5']") ;Button Class, doesn't use name.
; Get element's coordinates
$oERect = _WD_ElementAction($sSession, $sElement, 'rect')
ConsoleWrite("Element Coords = " & $oERect.Item('x') & " / " & $oERect.Item('y') & " / " & $oERect.Item('width') & " / " & $oERect.Item('height') & @CRLF)
; Click search button
$sButton = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@name='BTC Markets']")
_WD_ElementAction($sSession, $sButton, 'click')
_WD_LoadWait($sSession, 2000)
$sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//input[@class='css-1vs0no5']")
$sValue = _WD_ElementAction($sSession, $sElement, 'property', 'value')
ConsoleWrite('value = ' & $sValue & @CRLF)
MsgBox($MB_ICONINFORMATION, "Demo complete!", "Click ok to shutdown the browser and console")
_WD_DeleteSession($sSession)
_WD_Shutdown()

Func SetupGecko()
_WD_Option('Driver', 'geckodriver.exe')
_WD_Option('DriverParams', '--log trace')
_WD_Option('DriverParams', '--binary "C:\Program Files\Mozilla Firefox\firefox.exe"')
_WD_Option('Port', 4444)
$sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"browserName": "firefox", "acceptInsecureCerts":true}}}'
EndFunc

On a side note, i considered getting the source but somehow, the values from the table do not show up in it, i don't understand much about browsers but i guess the table loads in a different manner.

screenshot - 23032021-2308.png

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Posted (edited)

hi @Danp2

i am stuck on some jQuery accordion giving me trouble selecting option which is not a select nor button

all controlled by java script      any way you can suggest  add a class name on a element

 

<table id="T301394438" title="" class="BaseTable"><colgroup cols="8"><col style="width: 80px;"><col style="width: 80px;"><col style="width: 100px;"><col style="width: 104px;"><col style="width: 99px;"><col style="width: 81px;"><col style="width: 59px;"><col style="width: 100px;"></colgroup>
<tbody>

here content appear in tables with ajax
<tr class="CLICKED">
one we click class name is added with some java script 
<tr class="" >
<tr class="">
<tr class="">
</tbody>

</table>

 i was not able to find Javascript controlling that click

i tried 

_WD_Attach($sSession,'Third Level Search')
$element = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath,"//*[@id='T301394438']/tbody/tr[2]")
_WD_ExecuteScript($sSession,"( document.getElementsByTagName('tr')[8].classList.add('Clicked');")

;or  another attempt

_WD_Attach($sSession,'Third Level Search')
$element = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath,"//*[@id='T301394438']/tbody/tr[2]")
_WD_ElementAction($sSession,$element,'click')
_WD_ElementAction($sSession,$element,'doubleclick')

page where i am running is third paage open with WD_attach and if i run javascript on browser console i see'clicked' class added somehow selection is managed with hover focus and click  i am not sure;

I am new with blog questions pls forgive me if it sounds silly or details are not complete

I have also tried with iframe there is only 1 empty iframe at different place

 

 

 

 

nothing works help me please :)

 

Edited by AshishSaklani
Posted

@AshishSaklani You will need to provide additional details before I can offer any suggestions on how to accomplish your task. Some general comments --

  • You mentioned "jQuery Accordion". I took a look at one of these and the HTML looked very different than what you posted.
  • Is the website publicly accessible?
    • If yes, please provide the URL.
    • If no, then try to find another website that can be used to demonstrate the problem
  • It's often helpful to see the resulting output from Scite.
  • If you need to perform a double click on an element, then you need to use _WD_ElementActionEx (your code likely generated an error because _WD_ElementAction doesn't support a doubleclick option)
  • Please show us the javascript you ran in the browser console.
Posted (edited)
12 hours ago, careca said:

Hi, im trying to interact with binance.com, i would like to press a button and retrieve a table, but it seems cant do any of that, looked into the demos, but couldn't figure it out.

What im trying to do: get into https://www.binance.com/en/markets, press BTC Markets, and get all the values from the table.

What i tried so far:

Hey @careca, why don't you try to use the Binance API? It is pretty mature and full of features, this way you can get the quotes directly from the source. If so, maybe AutoIt is not the best tool for this.

Take a look at this post about web requests: 

 

Binance get markets: https://api.binance.com/api/v3/exchangeInfo

Get all the tickers: https://www.binance.com/api/v3/ticker/bookTicker

The full API: https://github.com/binance/binance-spot-api-docs/blob/master/rest-api.md

Good lucky

Edited by Chuckero
Added some extra info.
Posted (edited)

Hi Dan,

I have problems with clicking the submit ("Anmelden") button on this page: https://vertriebspartner.dela.de/partner-login

$sSubmitXPath = "/html/body/main/div[1]/div/div/div/div/div/form/input[2]"
_WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, $sSubmitXPath)
_WD_ElementAction($sSession, $sElement, 'click')

$sSubmitXPath = "//*[@id="c1948"]/div/form/input[3]" ; also doesn't work even when 1948 is correct (changes sometime to 1949 or other).

On some clients it works, on others not (with chrome).

Is there a function to highlight or mark in another way what _WD_FindElement() has found?

Edited by HJL
Posted

In wd_helper.au3, _WD_HighlightElement

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

Posted

Thanks to both of you: 

_WD_HighlightElement works fine (I can use it for future problems) and

"//input[@type='submit']" is perfect because it helps against the changing number in the XPath. But the problem actually was the chrome-profile on one client. After deleting it everything was ok - I didn't find the reason, just a workaround.

Next problem, and I already tried ChroPath - how to get around with the numbers in the following XPath? Is it possible to do something like "input[id=*'btn_login'] or "input[id='main_'&*&'btn_login'] ?

image.thumb.png.704d4aef1d04ece0679f55d388c15250.png

 

Posted

hi dan,

i have some question regarding multi run .exe at the same time / simultaneously

i have multi exe with only difference login id n password..

so i want run all at same time. for now i only try 2 run at same time to see if the code work. 

is there any code to exchange here?

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

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

EndFunc

my error is when run 2.. only last one .exe work.. first one .exe error like this

image.png.20ae0f8aeb44eb7a1a3331ed63b3681b.png

 

thank in advance !!

Posted
53 minutes ago, Danp2 said:

@moxasya I believe that you have a couple of options --

  • Run a single instance of Chromedriver, which should be able to support multiple sessions
  • Run separate instances of Chromedriver where each one uses a unique port number.  I know this has been discussed previously on the forum, but can't recall if it was in this thread or the development one.

i try the first one. i found other discussion in here 

and u say put at beginning

Func SetupChrome()
    _WD_Option('DriverClose', False) ;addon to solve multiple session issue
    _WD_Option('Driver', 'C:\Setup\Tools\AutoIt\Common\chromedriver.exe')
    _WD_Option('Port', 9515)
    _WD_Option('DriverParams', '--log-path="' & @ScriptDir & '\chrome.log"')

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

EndFunc

however return error 

image.png.66c1d0472a051d845a29ec8e9202c20c.png

Posted

 

 

I made a code in VBA Excel with Selenium. And I need to pass it to Autoit. But I couldn't emulate the following instructions:

SwitchToFrame and SwitchToDefaultContent

example:

ch.SwitchToFrame (0)

and this other instruction:

ch.SwitchToDefaultContent

ch is:

Set ch = New Selenium.ChromeDriver

Does anyone know how to do it in Autoit? Thanks in advance.

 
 
 
 
 
 
 

 

 

image.png

Posted

@JMan14 In the future, please use ctrl-shift-v to paste normal or use the copy feature of google translator (instead of highlighting it). That way the text will appear "normal" size in your post. 🙂

If you want to switch frames using the Webdriver UDF, then you would do something like this --

; Switch to frame by index
_WD_FrameEnter($sSession, "0")

; Perform frame activity here

; Return to top level
_WD_FrameEnter($sSession, Null) ; You could also use _WD_FrameLeave here

Hope this helps. If I've misunderstood your goal, then please clarify for us.

Posted

Hi Dan,

is it possible to retrieve the XPath of a field or button when clicking it with the mouse? I often have to find XPathes and up to now I use "inspect" and "copy" in chrome. It would be much easier to have a script that retrieves the XPath of the clicked item in memory or into a variable like copy and paste.

 

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...