Here’s a step-by-step guide to turn your test project into a Node package that you can publish and reuse.
Tuesday, July 8, 2025
Publish your test project into a Node package (npmjs)
Wednesday, April 30, 2025
Chat locally using gpt4all application
To chat locally using the GPT4All application, you must download and set up the GPT4All desktop app or run it from source. Here’s a general guide to help you get started:
✅ Step-by-Step: Use GPT4All Locally
-
Download the GPT4All App:
-
Go to https://gpt4all.io.
-
Click Download, and choose your operating system (Windows, macos, or Linux).
-
-
Install and Launch:
-
Run the installer and follow the prompts.
-
Launch the GPT4All app after installation.
-
-
Download a Model:
-
Upon first launch, the app will prompt you to download a local LLM (e.g., Mistral, LLaMA, or GPT-J variants).
-
Choose a model based on your system's capabilities (larger models may require more RAM).
-
Start Chatting:
-
After the model loads, you can chat with it offline, directly on your machine.
- Recorded Session by using lLama 3.1 8B Instruct 128k model
🧠Things to Know
-
GPT4All runs fully offline, so no internet is needed after model download.
-
Performance depends on your system—older machines may struggle with larger models.
-
It's not GPT-4—it's a locally run LLM with decent capabilities but not on par with OpenAI’s GPT-4.
Thursday, April 10, 2025
Selenium Java - Warning/Errors and its solutions
✅ 1. org.openqa.selenium.NoSuchElementException
Cause: Trying to locate an element that does not exist on the page.
Solutions:
-
Ensure the element is present in the DOM and visible.
-
Add waits:
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10)); WebElement element = wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("elementId")));
-
Check locator correctness (
id
,xpath
,cssSelector
, etc.).
✅ 2. ElementNotInteractableException
Cause: Element is present but cannot be interacted with (e.g., it's hidden or disabled).
Solutions:
-
Use
WebDriverWait
to ensure it is clickable:WebElement element = wait.until(ExpectedConditions.elementToBeClickable(By.id("elementId")));
-
Scroll into view using JavaScript:
((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true);", element);
✅ 3. TimeoutException
Cause: Wait timed out before condition was met.
Solutions:
-
Increase wait time or optimize locator.
-
Use appropriate expected condition (e.g.,
presenceOfElementLocated
vsvisibilityOfElementLocated
).
✅ 4. StaleElementReferenceException
Cause: WebElement is no longer attached to the DOM.
Solutions:
-
Re-locate the element after page reload or DOM change:
element = driver.findElement(By.id("elementId"));
-
Use a try-catch block to retry locating the element.
✅ 5. SessionNotCreatedException
Cause: Browser version mismatch with WebDriver.
Solutions:
-
Make sure ChromeDriver/GeckoDriver matches your browser version.
-
Use WebDriverManager (for Maven):
WebDriverManager.chromedriver().setup();
✅ 6. WebDriverException: unknown error: DevToolsActivePort file doesn't exist
Cause: Usually in headless mode with Chrome on Linux.
Solutions:
-
Add Chrome options:
ChromeOptions options = new ChromeOptions(); options.addArguments("--no-sandbox"); options.addArguments("--disable-dev-shm-usage"); options.addArguments("--headless");
✅ 7. Deprecation Warnings
Cause: Some older APIs (like Thread.sleep
, implicitlyWait
without Duration
, etc.) are deprecated.
Solutions:
-
Replace deprecated code:
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10));
✅ 8. java.lang.NullPointerException
Cause: WebElement or WebDriver not initialized.
Solutions:
-
Check initialization:
WebDriver driver = new ChromeDriver(); // Not null
-
Ensure correct scope in frameworks like TestNG, JUnit, etc.
✅ 9. org.openqa.selenium.ElementClickInterceptedException
Cause: Another element overlays the clickable element (like a modal or popup).
Solutions:
-
Wait for overlay to disappear.
-
Use JS click:
((JavascriptExecutor) driver).executeScript("arguments[0].click();", element);
✅ 10. IllegalStateException: The driver executable does not exist
Cause: Path to WebDriver not set correctly.
Solutions:
-
Set system property or use WebDriverManager:
System.setProperty("webdriver.chrome.driver", "path/to/chromedriver");
Monday, April 7, 2025
Programming with Java using Notepad
EXAMPLE : ReversedString
Step 1: Install Java Development Kit (JDK)
- Download and install the latest version of the JDK from the Oracle website or OpenJDK.
- During installation, note the installation directory (e.g.,
C:\Program Files\Java\jdk-XX.X.X
). - Set up the Environment Variables:
- Add the
bin
directory of the JDK to thePATH
variable:- Go to Control Panel > System > Advanced System Settings > Environment Variables.
- Under "System Variables," find
Path
, click Edit, and add the path to the JDK'sbin
folder (e.g.,C:\Program Files\Java\jdk-XX.X.X\bin
).
- Add the
- Verify the installation:
- Open Command Prompt and type:You should see the installed Java version.
1java -version 2
- Open Command Prompt and type:
Step 2: Write a Java Program
- Open Notepad (or any text editor).
- Write your Java code. For example, a simple "Hello, World!" program:
1public class HelloWorld { 2 public static void main(String[] args) { 3 System.out.println("Hello, World!"); 4 } 5} 6
- Save the file with a
.java
extension:- File name must match the class name (e.g.,
HelloWorld.java
). - Save it in a directory of your choice (e.g.,
C:\JavaProjects
).
- File name must match the class name (e.g.,
Step 3: Compile the Java Program
- Open Command Prompt.
- Navigate to the directory where you saved the
.java
file:1cd C:\JavaProjects 2
- Compile the Java program using the
javac
command:1javac HelloWorld.java 2
- If there are no errors, this will generate a
HelloWorld.class
file in the same directory.
- If there are no errors, this will generate a
Step 4: Run the Java Program
- Run the compiled program using the
java
command:1java HelloWorld 2
- You should see the output:
1Hello, World! 2
Tips and Best Practices
- Indentation and Formatting: Use proper indentation to make your code readable.
- Error Handling: If you encounter errors during compilation, carefully read the error messages to identify and fix issues.
- Use Notepad++: For a better experience, consider using Notepad++, which provides syntax highlighting and other helpful features for coding.
Example Workflow
- Write the program in Notepad:
1public class MyProgram { 2 public static void main(String[] args) { 3 System.out.println("Java programming is fun!"); 4 } 5} 6
- Save it as
MyProgram.java
. - Open Command Prompt, navigate to the file's directory, and compile it:
1javac MyProgram.java 2
- Run the program:Output:
1java MyProgram 2
1Java programming is fun! 2