1. Open LR11 in the virtual machine and click the "Create/Edit Scripts" button
2. Select the web(HTTP/HTML) mode to record
3. Enter the recording interface. The first thing to fill in here is the URL Addres, which is the URL of our target website. There is also a path for script saving, which can be defined by yourself. LR is recorded by using IE browser by default. The website we demonstrate here is LR's own test website http://127.0.0.1:1080/webtours/ , a booking system, account is jojo, password is bean. First, you need to open the web service. After opening, you will see a green "X" in the toolbar, as shown in the following figure.
4. Click "OK" and the recording will start, as shown in the figure below. Now let's record a script for login and ticket booking
5. After stopping, the script will be generated automatically. The generated script is in C language, which requires certain coding basis and can be understood.
Next, I pasted the script and made a simple comment. Here, you can read it carefully and patiently or understand it. The basic process operation will open a page, and then submit the data
Action() { //Open the homepage of this website web_url("webtours", "URL=http://127.0.0.1:1080/webtours/", "TargetFrame=", "Resource=0", "RecContentType=text/html", "Referer=", "Snapshot=t1.inf", "Mode=HTML", EXTRARES, "Url=http://www.bing.com/favicon.ico", "Referer=", ENDITEM, LAST); //Wait function, which is equivalent to python sleep, can also be removed when optimizing scripts lr_think_time(119); //Submit form function web_submit_data("login.pl", "Action=http://127.0.0.1:1080/webtours/login.pl", "Method=POST", "TargetFrame=body", "RecContentType=text/html", "Referer=http://127.0.0.1:1080/webtours/nav.pl?in=home", "Snapshot=t2.inf", "Mode=HTML", ITEMDATA, "Name=userSession", "Value=125742.521020656ztzHiiApQcfDiiAHpcifff", ENDITEM, "Name=username", "Value=jojo", ENDITEM, "Name=password", "Value=bean", ENDITEM, "Name=JSFormSubmit", "Value=off", ENDITEM, "Name=login.x", "Value=0", ENDITEM, "Name=login.y", "Value=0", ENDITEM, LAST); //Open a page web_url("Search Flights Button", "URL=http://127.0.0.1:1080/webtours/welcome.pl?page=search", "TargetFrame=body", "Resource=0", "RecContentType=text/html", "Referer=http://127.0.0.1:1080/webtours/nav.pl?page=menu&in=home", "Snapshot=t3.inf", "Mode=HTML", LAST); //Submit Form web_submit_data("reservations.pl", "Action=http://127.0.0.1:1080/webtours/reservations.pl", "Method=POST", "TargetFrame=", "RecContentType=text/html", "Referer=http://127.0.0.1:1080/webtours/reservations.pl?page=welcome", "Snapshot=t4.inf", "Mode=HTML", ITEMDATA, "Name=advanceDiscount", "Value=0", ENDITEM, "Name=depart", "Value=Denver", ENDITEM, "Name=departDate", "Value=03/12/2019", ENDITEM, "Name=arrive", "Value=Denver", ENDITEM, "Name=returnDate", "Value=03/13/2019", ENDITEM, "Name=numPassengers", "Value=1", ENDITEM, "Name=seatPref", "Value=None", ENDITEM, "Name=seatType", "Value=Coach", ENDITEM, "Name=.cgifields", "Value=roundtrip", ENDITEM, "Name=.cgifields", "Value=seatType", ENDITEM, "Name=.cgifields", "Value=seatPref", ENDITEM, "Name=findFlights.x", "Value=58", ENDITEM, "Name=findFlights.y", "Value=4", ENDITEM, LAST); web_submit_data("reservations.pl_2", "Action=http://127.0.0.1:1080/webtours/reservations.pl", "Method=POST", "TargetFrame=", "RecContentType=text/html", "Referer=http://127.0.0.1:1080/webtours/reservations.pl", "Snapshot=t5.inf", "Mode=HTML", ITEMDATA, "Name=outboundFlight", "Value=000;0;03/12/2019", ENDITEM, "Name=numPassengers", "Value=1", ENDITEM, "Name=advanceDiscount", "Value=0", ENDITEM, "Name=seatType", "Value=Coach", ENDITEM, "Name=seatPref", "Value=None", ENDITEM, "Name=reserveFlights.x", "Value=37", ENDITEM, "Name=reserveFlights.y", "Value=9", ENDITEM, LAST); web_submit_data("reservations.pl_3", "Action=http://127.0.0.1:1080/webtours/reservations.pl", "Method=POST", "TargetFrame=", "RecContentType=text/html", "Referer=http://127.0.0.1:1080/webtours/reservations.pl", "Snapshot=t6.inf", "Mode=HTML", ITEMDATA, "Name=firstName", "Value=Joseph", ENDITEM, "Name=lastName", "Value=Marshall", ENDITEM, "Name=address1", "Value=234 Willow Drive", ENDITEM, "Name=address2", "Value=San Jose/CA/94085", ENDITEM, "Name=pass1", "Value=Joseph Marshall", ENDITEM, "Name=creditCard", "Value=", ENDITEM, "Name=expDate", "Value=", ENDITEM, "Name=oldCCOption", "Value=", ENDITEM, "Name=numPassengers", "Value=1", ENDITEM, "Name=seatType", "Value=Coach", ENDITEM, "Name=seatPref", "Value=None", ENDITEM, "Name=outboundFlight", "Value=000;0;03/12/2019", ENDITEM, "Name=advanceDiscount", "Value=0", ENDITEM, "Name=returnFlight", "Value=", ENDITEM, "Name=JSFormSubmit", "Value=off", ENDITEM, "Name=.cgifields", "Value=saveCC", ENDITEM, "Name=buyFlights.x", "Value=27", ENDITEM, "Name=buyFlights.y", "Value=11", ENDITEM, LAST); return 0; }