# How to use AI to write code?

SimplifyQA’s Code Editor comes with built-in AI asasistance to help testers and developers generate, correct, and refine custom automation methods directly within the tool. This feature enhances productivity by reducing manual effort and enabling smart code suggestions.

### AI Features in Code Editor

SimplifyQA’s Code Editor comes with AI assistance to speed up scripting:

1. **Fix Syntax or Code Errors (Ctrl + L)**
   * **Step 1:** Highlight the portion of code where you suspect a syntax or logic issue.
   * **Step 2:** Press **Ctrl + L**.
   * **Step 3:** The AI will analyse the selected code and return a corrected version.
   * **Step 4:** Review and accept the suggestion to replace the faulty code.

<figure><img src="/files/859FassZfH8ycdQW5dgt" alt=""><figcaption></figcaption></figure>

2. **Generate Code Using AI (Ctrl + I)**
   * **Step 1:** Inside the Code Editor, select the section where you want to generate new code.
   * **Step 2:** Press **Ctrl + I** to invoke the AI.
   * **Step 3:** A prompt input box will appear. Describe what you want the code to do.
   * **Step 4:** The AI will auto-generate the corresponding code and insert it at the selected location.
   * **Step 5:** Choose whether to Accept the auto-generated code or Reject.

<figure><img src="/files/wK1y2UDhTp8mWdHMGQk6" alt="" width="563"><figcaption></figcaption></figure>

<figure><img src="/files/f63DVmSIieB9QSXtaaUs" alt=""><figcaption><p>Auto-generated</p></figcaption></figure>

{% hint style="success" %}
**Tip:** Make your prompt specific for best results. Example: “Create a Java method to compare two strings ignoring case sensitivity.”
{% endhint %}

The AI capabilities in SimplifyQA’s Code Editor provide a powerful boost to automation engineers by offering instant code generation and error resolution. Whether you're speeding up test logic creation or ensuring clean syntax, this feature saves time and reduces manual errors, letting teams focus on writing smarter tests faster.

### Frequently Asked Questions (FAQs)

<details>

<summary>Can AI-generated code be edited manually?</summary>

Absolutely. Once generated, you can modify, extend, or combine it with your existing logic.

</details>

<details>

<summary>Is AI support available for all programming languages?</summary>

Currently, AI assistance is optimised for Java, as it is the default scripting language in SimplifyQA’s Code Editor.

</details>

<details>

<summary>Do I need internet access to use AI features in the Code Editor?</summary>

Yes, AI code generation and syntax correction require an active internet connection.

</details>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.simplifyqa.ai/code-editor/how-to-use-ai-to-write-code.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
