This repository was archived by the owner on Sep 17, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
API Reference
waxnet edited this page Sep 22, 2024
·
32 revisions
This section is designed to provide you with comprehensive information and examples to help you understand the Synth API.
If you have any questions or need further assistance, don’t forget to check out our Community & Support page.
- WriteToFile
- AppendToFile
- ReadFromFile
- DeleteFile
- CreateFolder
- DeleteFolder
- DoesFileExist
- DoesFolderExist
driver = StartDriver(browser, width, height, userAgent)-
browser (string)
Specifies the name of the browser to launch (e.g. "chrome", "firefox"). -
width (number)
Sets the width of the browser window in pixels. -
height (number)
Sets the height of the browser window in pixels. -
userAgent (string - optional)
Defines the user agent string for the browser. This string is sent with requests to simulate different browsers or devices.
-
driver (Driver)
Driver class.
local driver = StartDriver("chrome", 450, 600)
driver:Browse("https://github.com/waxnet/Synth")
Wait(3)
driver:Quit()data = GetRandomString(length)-
length (number)
Specifies the length of the random string.
-
data (string)
Random string.
Print(GetRandomString(20))data = GetRandomNumber(minimum, maximum)-
minimum (number)
Specifies the lower bound of the range. -
maximum (number)
Specifies the upper bound of the range.
-
data (number)
Random number.
Wait(GetRandomNumber(1, 10))
Print("Hello World!")Print(text, color)-
text (string)
Text to be printed on screen. -
color (string)
Text color. (default white)
Print("Hello World!", "Red")data = Input(text, color)-
text (string)
Text to be printed on screen. -
color (string)
Text color. (default white)
-
data (string)
Input text from user.
local answer = Input("Do you want to print 'Hello World!' ? : ")
if answer == "y" then
Print("Hello World!")
endClear()- Clears screen.
Print("Hello World! 1")
Clear()
Print("Hello World! 2")data = SendGetRequest(url)- url (string) Url to make the request to.
-
data (string)
Returns the response content or error data if the request failed.
local data = SendGetRequest("https://www.mywebsite.com/text.txt")
Print(data)data = SendPostRequest(url, jsonData)- url (string) Url to make the request to.
- jsonData (table) Json data to send with the request.
-
data (string)
Returns the response content or error data if the request failed.
local data = SendPostRequest(
"https://www.mywebsite.com",
{
name = "John",
age = 30
}
)
Print(data)data = DownloadFile(url, filePath)- url (string) Url of the file to download.
- filePath (string) Path of the file to write to.
-
data (bool)
True if the file was downloaded successfully, false otherwise.
local success = DownloadFile("https://www.mywebsite.com/image.png", "myimage.png")
if success then
Print("File downloaded successfully.")
endWriteToFile(filePath, data)-
filePath (string)
Path of the file to write to. -
data (string)
Text to write to file.
WriteToFile("data.txt", "1234567890")AppendToFile(filePath, data)-
filePath (string)
Path of the file to write to. -
data (string)
Text to append to file.
AppendToFile("data.txt", "\n1234567890")data = ReadFromFile(filePath)-
filePath (string)
Path of the file to write to.
-
data (string)
Text from file. (empty string if file is not found)
local data = ReadFromFile("data.txt")
Print(data)DeleteFile(filePath)-
filePath (string)
Path of the file to delete.
if DoesFileExist("data.txt") then
DeleteFile("data.txt")
endCreateFolder(folderPath)-
folderPath (string)
Path of the folder to create.
CreateFolder("MyScript")DeleteFolder(folderPath)-
folderPath (string)
Path of the folder to delete.
if DoesFolderExist("MyScript") then
DeleteFolder("MyScript")
enddata = DoesFileExist(filePath)-
filePath (string)
Path of the file to check.
-
data (bool)
True if file exists, false otherwise.
if DoesFileExist("data.txt") then
DeleteFile("data.txt")
enddata = DoesFolderExist(folderPath)-
folderPath (string)
Path of the folder to check.
-
data (bool)
True if folder exists, false otherwise.
if DoesFolderExist("MyScript") then
DeleteFolder("MyScript")
endSetScriptTitle(title)-
title (string)
Specifies the script title.
SetScriptTitle("My Script")data = Wait(seconds)-
seconds (number)
Specifies the amount of seconds to wait. (default is 0)
-
data (bool)
Returns true after waiting.
local counter = 0
repeat
Print("Hello World!")
Wait(1)
counter = counter + 1
until counter == 10| Property | Type | Description |
|---|---|---|
Title |
string | Gets the title of the browser window. |
Url |
string | Gets the URL the browser is currently displaying. |
PageSource |
string | Gets the source of the page last loaded by the browser. |
Window |
Window | Gets the driver window. |
Network |
Network | Gets the driver network manager. |
Cookies |
Cookies | Gets the driver cookie manager. |
| Method | Type | Description |
|---|---|---|
Quit() |
void | Quits the driver. |
Browse(url : string) |
void | Load a new web page in the browser window. |
Forward() |
void | Move a single "item" forward in the browser's history. |
Back() |
void | Move a single "item" backward in the browser's history. |
Refresh() |
void | Refreshes the current page. |
FindElement(identifier : string, method : string - optional) |
Element | Finds the first element using the given method. |
FindElements(identifier : string, method : string - optional) |
Element Array | Finds elements using the given method. |
WaitForElement(timeout : number, identifier : string, method : string - optional) |
Element | Waits for the first element using the given method. |
local driver = StartDriver("chrome", 450, 600)
driver:Browse("https://www.supercoolwebsite.com/")
-- (Id, Name, ClassName, TagName, LinkText, PartialLinkText, CssSelector, XPath)
local textBox = driver:WaitForElement(30, "TextBox", "Id")
local submitButton = driver:WaitForElement(30, "SubmitButton") -- default method is Id
textBox.Text = "Hello World!"
submitButton:Click()
local buttons = driver:FindElements("Buttons")
for index = 0, buttons.Length - 1 do
local button = buttons[index]
button:Click()
end
driver:Quit()| Property | Type | Description |
|---|---|---|
Text |
string | Gets or sets the visible text of the element. |
TagName |
string | Gets the tag name of the element. |
Enabled |
bool | True if the element is enabled, false otherwise. |
Selected |
bool | True if the element is selected, false otherwise. |
Displayed |
bool | True if the element is displayed, false otherwise. |
Position |
Vector2 | Gets the position of the element. |
Size |
Vector2 | Gets the size of the element. |
| Method | Type | Description |
|---|---|---|
Click() |
void | Clicks the element. |
Submit() |
void | Submits the element to the web server. |
GetAttribute(attributeName : string) |
string | Gets the value of the specified attribute for the element. |
GetCssValue(propertyName : string) |
string | Gets the value of the specified CSS property for the element. |
GetDomProperty(propertyName : string) |
string | Gets the value of the specified JavaScript property for the element. |
FindElement(identifier : string, method : string - optional) |
Element | Finds the first sub-element using the given method. |
FindElements(identifier : string, method : string - optional) |
Element Array | Finds sub-elements using the given method. |
local driver = StartDriver("chrome", 450, 600)
driver:Browse("https://www.supercoolwebsite.com/")
-- (Id, Name, ClassName, TagName, LinkText, PartialLinkText, CssSelector, XPath)
local textBox = driver:WaitForElement(30, "TextBox", "Id")
local submitButton = driver:WaitForElement(30, "SubmitButton") -- default method is Id
textBox.Text = "Hello World!"
submitButton:Click()
local buttons = driver:FindElements("Buttons")
for index = 0, buttons.Length - 1 do
local button = buttons[index]
button:Click()
end
driver:Quit()| Property | Type | Description |
|---|---|---|
Position |
Vector2 | Gets or sets the position of the driver window. |
Size |
Vector2 | Gets the sets the size of the driver window. |
| Method | Type | Description |
|---|---|---|
Fullscreen() |
void | Fullscreens the driver window. |
Maximize() |
void | Maximizes the driver window. |
Minimize() |
void | Minimizes the driver window. |
local driver = StartDriver("chrome", 450, 600)
local window = driver.Window
window.Position = Vector2.New(400, 400)
window.Size = Vector2.New(400, 400)| Method | Type | Description |
|---|---|---|
Connect(function : function, traffic : string) |
Connection | Connects a function to the specified network traffic and returns a connection handle. |
Disconnect(connection : Connection) |
void | Disconnects a connection. |
StartMonitoring() |
void | Starts monitoring the network traffic. |
StopMonitoring() |
void | Stops monitoring the network traffic. |
local driver = StartDriver("chrome", 450, 600)
Wait(3)
local network = driver.Network
local connection = network:Connect(function(data)
Print(data.Url)
end, "requests")
network:StartMonitoring()
driver:Browse("https://google.com/")
network:StopMonitoring()
network:Disconnect(connection)
Wait(3)
driver:Quit()| Property | Type | Description |
|---|---|---|
AllCookies |
Cookie Array | Gets all Cookies defined for the current page. |
| Method | Type | Description |
|---|---|---|
GetCookie(cookieName : string) |
Cookie | Gets a Cookie with the specified name. |
AddCookie(cookie : Cookie) |
void | Adds a Cookie to the current page. |
DeleteCookie(cookie : Cookie) |
void | Deletes the specified Cookie from the page. |
DeleteCookie(cookieName : string) |
void | Deletes the Cookie with the specified name from the page. |
DeleteAllCookies() |
void | Deletes all Cookies from the page. |
local cookie = Cookie.New("TestCookie", "TestValue")
Print(cookie.Name)
Print(cookie.Value)| Method | Type | Description |
|---|---|---|
New(x : int, y : int) |
Vector2 | Creates a new Vector2 instance. |
| Property | Type | Description |
|---|---|---|
X |
int | Gets or sets the X value. |
Y |
int | Gets or sets the Y value. |
local vector2 = Vector2.New(100, 100)
Print("X : "..tostring(vector2.X).." - Y : "..tostring(vector2.Y))
vector2.X = 200
vector2.Y = 200
Print("X : "..tostring(vector2.X).." - Y : "..tostring(vector2.Y))| Property | Type | Description |
|---|---|---|
Id |
string | Gets the request id. |
Url |
string | Gets the request url. |
Method |
string | Gets the HTTP request method. |
PostData |
string | Gets the request post data. |
Headers |
Dictionary<string, string> | Gets the request headers. |
local driver = StartDriver("chrome", 450, 600)
Wait(3)
local network = driver.Network
local connection = network:Connect(function(data)
Print(data.Url)
end, "requests")
network:StartMonitoring()
driver:Browse("https://google.com/")
network:StopMonitoring()
network:Disconnect(connection)
Wait(3)
driver:Quit()| Property | Type | Description |
|---|---|---|
Id |
string | Gets the request id. |
Url |
string | Gets the response url. |
StatusCode |
number | Gets the response status code. |
Body |
string | Gets the response body. |
Content |
string | Gets the response content. |
ResourceType |
string | Gets the response resource type. |
Headers |
Dictionary<string, string> | Gets the response headers. |
local driver = StartDriver("chrome", 450, 600)
Wait(3)
local network = driver.Network
local connection = network:Connect(function(data)
Print(data.Url)
end, "responses")
network:StartMonitoring()
driver:Browse("https://google.com/")
network:StopMonitoring()
network:Disconnect(connection)
Wait(3)
driver:Quit()| Method | Type | Description |
|---|---|---|
New(name : string, value : string, path : string - optional, domain : string - optional) |
Cookie | Creates a new Cookie instance. |
NewSecure(name : string, value : string, path : string, domain : string, secure : bool, isHttpOnly : bool, sameSite : string) |
Cookie | Creates a new secure Cookie instance. |
| Property | Type | Description |
|---|---|---|
Name |
string | Gets the Cookie name. |
Value |
string | Gets the Cookie value. |
Path |
string | Gets the Cookie path. |
Domain |
string | Gets the Cookie domain. |
Expiry |
string | Gets the Cookie expiry date. (dd/MM/yy-HH:mm:ss) |
Secure |
bool | True if cookie is secure, false otherwise. |
IsHttpOnly |
bool | True if cookie is http only, false otherwise. |
SameSite |
string | Gets the same site setting for the Cookie. |
local cookie = Cookie.New("TestCookie", "TestValue")
Print(cookie.Name)
Print(cookie.Value)Happy Scripting!