Web Automation Tips and Tricks
Web Automation have four sections:
- Menu file will help you use some of feature of program like login, logout, register...,
- ToolBar menu will help you work with some item you will usually using like record, run,...,
- Web Browser will display website when you suffering,
- Developer Tools that place will automate every of program by JavaScript language
Using Web Automation to Login Gmail
Open program and enter link http://www.gmail.com and click button go
Right click every where on Web Browser, click Go then it show question "Do you want go to website?", if you choose yes it will get current URL you enter on the textbox, else it will get XPath of location where you right click then go to the link of the xpath.
Then it will show you Developer Tools with code JavaScript to control this function
Right click on textbox username, click fill, enter username then click ok, repeat for password
Right click on Button Login select click.
You must enter two line to ensure website load done before you continue, then you click Run and then program will go to Gmail for you.
go("https://accounts.google.com/ServiceLogin?service=mail&passive=true&rm=false&continue=http://mail.google.com/mail/&scc=1<mpl=default<mplcache=2"); sleep(5,false); fill("/html/body/div/div[2]/div/div/form/div/input","thang@gmail.com"); fill("/html/body/div/div[2]/div/div/form/div[2]/input","password"); sleep(5,false); click("/html/body/div/div[2]/div/div/form/input[12]");
What do you do with Web Automation?
Here is function of Web Automation, you can try by write function bellow with your parameter then click run and see what happen, notes some function need authentication to work like function number: 59 to 64, rest of another function you don't need to login.
- Open new tab:
tabnew();
- Close current tab:
tabclose();
- Go to website by url or xpath:
go(url);
orgo(xpath);
- Go back:
back();
- Go next:
next();
- Reload browser:
reload();
- Stop browser:
stop();
- Wait until Web Browser has loaded or timer to wait Web Browser load:
sleep(seconds, isBreakWhenWBCompleted)
- Close application:
exit();
- Click to element:
click(xpath);
- Write log to Preview Tab:
log(value);
- Clear log write on Preview:
clearlog();
- Extract data from xpath: extract(xpath);
- Fill data to element on Web Browser:
fill(xpath, value);
- Select dropdown value:
filldropdown(xpath, index);
- Convert string to Object javascript:
toObject(xpath);
- Get all link in the area of xpath, it will stop until program go all of link :
browser(xpath);
- Reset list website to unread so program can go back and browser continue :
resetlistwebsite();
- Take snapshot of website:
takesnapshot(url);
- Create folder:
createfolder(path);
- Get list folder from path:
getfolders(path);
- Create file:
save(content, location, isOverride);
- Get list file from path:
getfiles(path);
- Download a file:
download(url, location);
- Read file:
read(path);
- Remove file:
remove(path);
- Remove folder:
removefolder(path);
- Open explorer and select file:
explorer(path);
- Run code from string:
excute(code);
- Logoff:
logoff();
- Lockworkstation:
lockworkstation();
- Forcelogoff:
forcelogoff();
- Reboot:
reboot();
- Shutdown:
shutdown();
- Hibernate:
hibernate();
- Standby:
standby();
- Run application:
runcommand(path);
- Get current url of current tab:
getcurrenturl();
- Get browser height:
getheight();
- Get title of website:
gettitle();
- Get all link from xpath:
getlinks(xpath);
- Get content of web browser:
getCurrentContent();
- Get path of Web Automation:
getCurrentPath();
- Read cell of excel file:
readCellExcel(path, sheetname, row, column);
- Write excel file:
writeCellExcel(path, sheetname, cellname, value);
- Load HTML file:
loadHTML(path);
- Convert json string to Object:
textToJSON(jsonstring);
- Login:
login(username, password);
- Register:
register(username, email, password, confirm);
- OCR:
ocr(path, language);
- Mouse Up:
MouseUp(mouseButton, lastTime);
- Mouse Down:
MouseDown(mouseButton, lastTime);
- Mouse Click:
MouseClick(mouseButton, lastTime);
- Mouse Doble Click:
MouseDoubleClick(mouseButton, lastTime);
- Mouse Move:
MouseMove(x, y, isShow, lastTime);
- Mouse Wheel:
MouseWheel(delta, lastTime);
- Key Down:
KeyDown(delta, lastTime);
- Key Up:
KeyUp(delta, lastTime);
- Get Account By:
getAccountBy(name);
- Get Database:
getDatabases(name);
- Get Tables:
getTables(name, dbName);
- Get Columns:
getColumns(name, dbName, table);
- Get Rows:
getRows(name, dbName, sql);
- Excute SQL Query:
excuteQuery(name, dbName, sql);
That all function of Web Automation, every function is javascript function so it have return or not return value, some time you get value is string, some time you will get value is object, it base on my C# function.
By combine each function together you can automate alot of thing, automate fill textbox, click button, extract any kind of data, automate create, delete, file, folder, automate extract data from website and save it to excel file easily, update data to excel file, read data from excel file, control your mouse, your keyboard.....