Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Javascript Articles
Page 427 of 534
How to create and use a Syntax Highlighter with JavaScript?
A syntax highlighter in JavaScript allows you to apply styling to specific code elements like keywords, strings, or HTML tags. This tutorial shows how to create a basic highlighter using regular expressions and DOM manipulation. Example: HTML Link Highlighter This example highlights HTML anchor tags by applying custom CSS styles: body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } .colorLinks { color: rgb(131, 44, 212); ...
Read MoreHow to create animations using JavaScript?
JavaScript animations are created by repeatedly changing CSS properties over time using functions like setInterval() or requestAnimationFrame(). This allows you to create smooth visual effects directly in the browser. Basic Animation Principles JavaScript animations work by: Selecting the element to animate Using a timer function to repeatedly update CSS properties Incrementing position, size, or other properties each frame Stopping the animation when the target is reached Example: Moving and Morphing Animation ...
Read MoreHow to create a weight converter with HTML and JavaScript?
Creating a weight converter with HTML and JavaScript involves building a simple form that takes weight input in one unit and converts it to another unit in real-time. This tutorial demonstrates how to create a kilogram to gram converter. HTML Structure The HTML provides the basic structure with an input field for kilograms and a display area for the converted grams: body{ font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; } input, span{ ...
Read MoreHow to create a temperature converter with HTML and JavaScript?
To create a temperature converter with HTML and JavaScript, you need to combine form elements with JavaScript functions to perform real-time temperature conversions. Complete Temperature Converter Example body{ font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; max-width: 600px; margin: 50px auto; padding: 20px; } .converter-container { background: #f8f9fa; border-radius: ...
Read MoreHow to create a length converter with HTML and JavaScript?
To create a length converter with HTML and JavaScript, you'll need to combine HTML form elements with JavaScript functions to handle the conversion logic. This tutorial demonstrates building a simple kilometer-to-meter converter. HTML Structure The converter uses an input field for kilometers and displays the converted meters value. The oninput and onchange events trigger the conversion function automatically as you type. Complete Example body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; padding: 20px; ...
Read MoreHow to create a speed converter with HTML and JavaScript?
To create a speed converter with HTML and JavaScript, we'll build a simple web application that converts kilometers per hour to meters per second. This involves HTML for the interface and JavaScript for the conversion logic. HTML Structure The HTML creates the user interface with an input field for entering speed values and a display area for the converted result: body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; padding: 20px; ...
Read MoreHow to get the value of the edit box in Selenium?
In Selenium WebDriver, retrieving values from edit boxes (input fields) requires specific methods since getText() often returns empty strings for input elements. Here are the most effective approaches to extract values from edit boxes. Why getText() May Not Work The getText() method retrieves visible text content, but input fields store their values in the "value" attribute rather than as text content. This is why getText() often returns empty strings for input elements. Method 1: Using getAttribute("value") The most reliable approach is using the getAttribute() method to retrieve the "value" attribute: import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; ...
Read MoreAmong id, name, xpath and css, which locator should be used?
When selecting locators for web automation, the choice depends on element uniqueness, performance requirements, and traversal needs. Here's a comprehensive guide to choosing the right locator strategy. Locator Priority Order The recommended priority order for locator selection: Priority Locator Reason 1 id Fastest, most reliable if unique 2 name Fast, good for form elements 3 CSS Selector Fast, flexible, good performance 4 XPath Most flexible but slower When to Use Each Locator ID Locator Use when elements have unique IDs. This is the ...
Read MoreHow to identify the nth sub element using xpath?
We can identify the nth sub element using xpath in the following ways: By adding square brackets with index. By using position() method in xpath. Method 1: Using Square Brackets with Index The most common approach is to add square brackets with the desired index number after the element selector: // Select the 2nd div element //div[2] // Select the 3rd li element inside ul //ul/li[3] // Select the first input with type='text' //input[@type='text'][1] Method 2: Using position() Function The position() function provides another way to target elements ...
Read MoreWhat does fluent wait perform?
Fluent wait is a dynamic wait mechanism in Selenium that allows the WebDriver to pause and repeatedly check for a condition at regular intervals before throwing an exception. Unlike implicit wait, FluentWait provides more control over polling frequency and exception handling. How FluentWait Works FluentWait monitors the DOM at regular intervals (defined by polling frequency) rather than constantly checking. For example, if you set a 30-second timeout with 3-second polling, the driver will check the condition every 3 seconds for up to 30 seconds before timing out. Syntax Wait wait = new FluentWait(driver) ...
Read More