Jump to content

Webdriver UDF(based On External Exe)


n3wbie
 Share

Recommended Posts

Please Spare me for errors

M totally Raw At programming stuffs So please forgive me

Coming to udf 

Why was it required: Udf Already Available had to start with an extension and ws a bit tricky to be used also it was a bit obsolute

What Are Functionalities of new udf: not much but a better way of interacting and userfriendliness, using external exe which can workaround with many other browsers

Requirements: Chromedriver.exe(available freely)(Chrome)(Please Use version 2.28 as further versions/Previous versions sometime create problems)

                             Geckodriver.exe(available freely)(Mozilla FF)There are some problems with this version m working to resolve same and make udf work with both browsers

                             JSON UDF 

                             Browserudf.au3

Example Script For facebook Login Quite Simple to use

#Include <browserudf.au3>
$id=Browser_Setings(9515,"D:\Desktop\Vinfur\chromedriver.exe")
$session=Browser_create_session()
Browser_openurl($session,"https://www.facebook.com/")
$element=Browser_getelement($session,"name","email")
browser_setelement($session,$element,"Username type here")
$element=Browser_getelement($session,"id","pass")
browser_setelement($session,$element,"Password")
$element=Browser_getelement($session,"id","u_0_r")
browser_actions_click($session,$element)
Browser_Setings_close($id)

 

I Know There are thousands of bugs so please go on correcting me so that i will improve and also udf

And Also Sorry that i didnt make any error checking mechanism for any function

but as i couldnt get all errors listed/documented anywhere so i will update it as we go ahead

and one more thanks to 

 

Edited by n3wbie
Updated UDF Errors
Link to comment
Share on other sites

I would suggest yes, change the function names.

 

 

 

Link to comment
Share on other sites

1 hour ago, junkew said:

I would suggest yes, change the function names.

 

 

 

I First Had Plan to implement Full But Than Dropped as there are so many versions of drivers and response are a bit different to sort for result

like chrome driver gives direct session in main json obj while geckodriver gives in as value->session

Making it complaint to all was not possible so even i dropped idea of using full json and wherever required i switched to using stringregex()

Also webdriver implementation is getting updated and many a times functions are getting changed 

like session/sessionid/execute was dropped and instead /execute/sync was formed 

now some drivers are having this implementation while some use old

also some capabilities arent well implemented in some drivers like wise other may work flawless

So basically my main aim was to provide a basic start to community using webdriver concept.Also Keeping in Mind that maximum may get benefit(in terms of drivers)

Currently m working it to keep it in line for basic operations (ie navigation and get source)

Once I Solve and inline with both webdriver along with error checking mechanism we will take up more .

i will take advise and change its name to webdriver and all functions here after will be named as webdriver_function names

May b in future someone can take them further if not me.

Link to comment
Share on other sites

On 7/10/2017 at 3:51 PM, junkew said:

I would suggest yes, change the function names.

 

 

 

Updated Example Script Have A look

Link to comment
Share on other sites

On 7/9/2017 at 9:53 PM, argumentum said:

Would you give examples on how to use this ?. Thanks for sharing.

Updated it to work with mozilla ff and chrome and most probably with all other drivers

Example Script Updated in first post would like you to test same. Extremely sorry for delay

please update me for other issue

Link to comment
Share on other sites

  • 1 month later...
On 8/3/2017 at 1:00 PM, n3wbie said:

Updated it to work with mozilla ff and chrome and most probably with all other drivers

Example Script Updated in first post would like you to test same. Extremely sorry for delay

please update me for other issue

Thank you for this udf. May i ask if you can help me to get img src? 

Link to comment
Share on other sites

31 minutes ago, woodv said:

Thank you for this udf. May i ask if you can help me to get img src? 

Do u need link from img src?

U can use source to get full source code and use regex and other string manupulation to get that src

 

If you need more help please post more info like webpage and other info

Link to comment
Share on other sites

10 minutes ago, n3wbie said:

Do u need link from img src?

U can use source to get full source code and use regex and other string manupulation to get that src

 

If you need more help please post more info like webpage and other info

yes i need it. I'd like to use xpath to get link but your udf doesn't support it yet. I can get ElementId of img tag but i cant retrieve link from img src attribute for now.

Link to comment
Share on other sites

3 minutes ago, woodv said:

yes i need it. I'd like to use xpath to get link but your udf doesn't support it yet. I can get ElementId of img tag but i cant retrieve link from img src attribute for now.

Yes my udf doesnt support src

U can currently do it with only source

 

I have updated this in my to do list

Also there are some script breaking changes in next version of udf so please beware

Link to comment
Share on other sites

3 minutes ago, n3wbie said:

Yes my udf doesnt support src

U can currently do it with only source

 

I have updated this in my to do list

Also there are some script breaking changes in next version of udf so please beware

Thank you. I'm sure waiting for upcoming update. 

Link to comment
Share on other sites

On 9/13/2017 at 8:43 PM, woodv said:

Thank you. I'm sure waiting for upcoming update. 

quick use for src

Func browser_get_attribute($session, $elementid,$attribute)
    $source = _BrowserGET($baseurl & "/session/" & $session & "/element/" & $elementid & "/attribute/"&$attribute)
    $json = _JSONDecode($source)
    $result = _JSONGet($json, "value")
    Return $result
EndFunc   ;==>browser_get_Elementvalue

Add this in ur script and try once if it works, i havnt tested it yet

Link to comment
Share on other sites

19 minutes ago, n3wbie said:

quick use for src

Func browser_get_attribute($session, $elementid,$attribute)
    $source = _BrowserGET($baseurl & "/session/" & $session & "/element/" & $elementid & "/attribute/"&$attribute)
    $json = _JSONDecode($source)
    $result = _JSONGet($json, "value")
    Return $result
EndFunc   ;==>browser_get_Elementvalue

Add this in ur script and try once if it works, i havnt tested it yet

It always returns "Default" string

Link to comment
Share on other sites

On 9/13/2017 at 9:21 PM, woodv said:

It always returns "Default" string

Func browser_get_attribute($session, $elementid,$attribute)
    $source = _BrowserGET($baseurl & "/session/" & $session & "/element/" & $elementid & "/attribute/"&$attribute)
    $json = _JSONDecode($source)
    $result = _JSONGet($json, "value")

    Return $source
EndFunc   ;==>browser_get_Elementvalue

use above code and post return value here

Link to comment
Share on other sites

$chrome=Browser_Setings(9515,@ScriptDir & "\chromedriver.exe")
$session=Browser_create_session()
Browser_openurl($session,"https://www.google.com")
$element=Browser_getelement($session,"xpath","//*[@id='hplogo']")
$imgsrc=browser_get_attribute($session,$element,"scr")
MsgBox(0,"",$imgsrc)
Browser_Setings_close($chrome)

getattribute.png

My test code and result

Link to comment
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
 Share

×
×
  • Create New...