Frequently Asked Questions
Q. How do I debug my script?
Ans: Since the release of 0.5.0
version, AgentQL SDK has an internal debug mode, which is implemented as a context manager that could be wrapped around your script. Once a crash happens or the script finishes running, the debug mode will save the following contents to the folder path specified during setup process or AGENTQL_DEBUG_PATH
environment variable (default path is YOUR_HOME_PATH/.agentql/debug
):
- Log of each action taken by AgentQL SDK.
- Error Information (if the script crashes).
- Screenshot of each page on which a
query
action is performed. - Accessibility Tree of the last page before the crash or the end of script.
- Meta information (OS, Python version, AgentQL version)
The following script is an example of how you could use this debug mode:
Q. How do I specify the format of data returned by AgentQL?
Ans: Since the release of 0.4.7
version, AgentQL supports providing context to query in the following way:
As you can see, by providing formatting instructions as a context into the query, you could instruct AgentQL to return the expected data format.
Q. While writing AgentQL Script, how do I ensure the web page is loaded entirely?
Ans: Loading web page entirely right now is considered as an application logic, as it is difficult to objectively tell what does it mean that entire web page is loaded. As some websites have lazy loading and are infinitely scroablle and so for those kind of web pages what does it mean to load the entire web page.
You can use Playwright API to scroll the page up and down to load the more content.
Q. How do I make sure that my script waits enough for all the element to appear on the page?
Ans:
AgentQL SDK provides the wait_for_page_ready_state()
API to determine page readiness. This method waits for the page to be in a ready state and all the necessary network requests to be completed. However, there are some cases where the page might not be ready even after the method returns. This could be due to the dynamic nature of the page. In such cases, you can use the page.wait_for_timeout
function to add a additional delay to your script.