n3wbie Posted July 9, 2017 Posted July 9, 2017 (edited) 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 August 3, 2017 by n3wbie Updated UDF Errors mLipok and woodv 2
argumentum Posted July 9, 2017 Posted July 9, 2017 Would you give examples on how to use this ?. Thanks for sharing. Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
n3wbie Posted July 9, 2017 Author Posted July 9, 2017 3 minutes ago, argumentum said: Would you give examples on how to use this ?. Thanks for sharing. Yes sure, Even there are some more functions to be added and some bugs fixes I ll update the same with examples Thanks for suggesting argumentum 1
junkew Posted July 9, 2017 Posted July 9, 2017 Good start. Maybe mix with edge webdriver examples. See FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets
n3wbie Posted July 10, 2017 Author Posted July 10, 2017 7 hours ago, junkew said: Good start. Maybe mix with edge webdriver examples. See Mostly my functions will work with edge also I do t have edgeso some one could check after i post example
junkew Posted July 10, 2017 Posted July 10, 2017 As you use webdriver concept maybe suggestion to rename to webdriver.au3 as there are also drivers for non browsers https://github.com/Microsoft/WinAppDriver FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets
n3wbie Posted July 10, 2017 Author Posted July 10, 2017 13 minutes ago, junkew said: As you use webdriver concept maybe suggestion to rename to webdriver.au3 as there are also drivers for non browsers https://github.com/Microsoft/WinAppDriver Should i change function names even? Please suggest
junkew Posted July 10, 2017 Posted July 10, 2017 I would suggest yes, change the function names. But it depends on your goal. Full implementation of https://www.w3.org/TR/webdriver/ as is done for other languages then I would suggest to follow the Java webdriver implementation regarding function names. which basically is described here https://seleniumhq.github.io/selenium/docs/api/java/org/openqa/selenium/WebDriver.html Then follow getPageSource() Get the source of the last loaded page. instead of getSource as you did in your implementation Getting dot syntax like $driver.getPageSource can be achieved with a. AutoItObject library b. and maybe in future with CLR.AU3 (we are not far enough to have that properly working) FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets
n3wbie Posted July 10, 2017 Author Posted July 10, 2017 1 hour ago, junkew said: I would suggest yes, change the function names. But it depends on your goal. Full implementation of https://www.w3.org/TR/webdriver/ as is done for other languages then I would suggest to follow the Java webdriver implementation regarding function names. which basically is described here https://seleniumhq.github.io/selenium/docs/api/java/org/openqa/selenium/WebDriver.html Then follow getPageSource() Get the source of the last loaded page. instead of getSource as you did in your implementation Getting dot syntax like $driver.getPageSource can be achieved with a. AutoItObject library b. and maybe in future with CLR.AU3 (we are not far enough to have that properly working) 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.
n3wbie Posted August 1, 2017 Author Posted August 1, 2017 On 7/10/2017 at 3:51 PM, junkew said: I would suggest yes, change the function names. But it depends on your goal. Full implementation of https://www.w3.org/TR/webdriver/ as is done for other languages then I would suggest to follow the Java webdriver implementation regarding function names. which basically is described here https://seleniumhq.github.io/selenium/docs/api/java/org/openqa/selenium/WebDriver.html Then follow getPageSource() Get the source of the last loaded page. instead of getSource as you did in your implementation Getting dot syntax like $driver.getPageSource can be achieved with a. AutoItObject library b. and maybe in future with CLR.AU3 (we are not far enough to have that properly working) Updated Example Script Have A look
n3wbie Posted August 3, 2017 Author Posted August 3, 2017 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 argumentum, junkew and PoojaKrishna 3
woodv Posted September 13, 2017 Posted September 13, 2017 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?
n3wbie Posted September 13, 2017 Author Posted September 13, 2017 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
woodv Posted September 13, 2017 Posted September 13, 2017 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.
n3wbie Posted September 13, 2017 Author Posted September 13, 2017 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
woodv Posted September 13, 2017 Posted September 13, 2017 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.
n3wbie Posted September 13, 2017 Author Posted September 13, 2017 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 woodv 1
woodv Posted September 13, 2017 Posted September 13, 2017 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
n3wbie Posted September 13, 2017 Author Posted September 13, 2017 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
woodv Posted September 13, 2017 Posted September 13, 2017 $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) My test code and result
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now