Skip to content

Commit d5639f2

Browse files
committed
Featured update db
1 parent 8e0d379 commit d5639f2

File tree

91 files changed

+2201
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+2201
-2
lines changed

README.md

+590-2
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
## [How do you run Protractor tests in headless mode?](#how-to-run-protractor-tests-in-headless-mode)
2+
3+
### How do you run Protractor tests in headless mode?
4+
5+
To run Protractor tests in headless mode, you can configure the `protractor.conf.js` file to use a headless browser like Chrome.
6+
7+
Example configuration:
8+
9+
```javascript
10+
capabilities: {
11+
'browserName': 'chrome',
12+
'chromeOptions': {
13+
args: ['--headless', '--disable-gpu', '--window-size=800x600']
14+
}
15+
},
16+
```
17+
18+
**Tags**: [advanced](./level/advanced), [Protractor](./theme/protractor), [Headless Testing](./theme/headless_testing)
19+
20+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
## [How do you check if a Queue is empty in JavaScript?](#how-to-check-if-a-queue-is-empty)
2+
3+
### How do you check if a Queue is empty in JavaScript?
4+
5+
To check if a queue is empty, you can verify if the queue's length is zero.
6+
7+
Example:
8+
9+
```javascript
10+
let queue = new Queue();
11+
console.log(queue.isEmpty()); // true
12+
```
13+
14+
**Tags**: [basic](./level/basic), [JavaScript](./theme/javascript), [Operations](./theme/operations)
15+
16+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
## [How do you implement a Queue in JavaScript?](#how-to-implement-a-queue-in-javascript)
2+
3+
### How do you implement a Queue in JavaScript?
4+
5+
A queue can be implemented using an array or linked list. For simplicity, let's use an array.
6+
7+
Example of a queue implementation using an array:
8+
9+
```javascript
10+
class Queue {
11+
constructor() {
12+
this.items = [];
13+
}
14+
enqueue(element) {
15+
this.items.push(element);
16+
}
17+
dequeue() {
18+
return this.items.shift();
19+
}
20+
peek() {
21+
return this.items[0];
22+
}
23+
isEmpty() {
24+
return this.items.length === 0;
25+
}
26+
}
27+
```
28+
29+
**Tags**: [basic](./level/basic), [JavaScript](./theme/javascript), [Implementation](./theme/implementation)
30+
31+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
## [How do you implement the dequeue operation in a Queue?](#how-to-implement-dequeue-operation-in-queue)
2+
3+
### How do you implement the dequeue operation in a Queue?
4+
5+
The dequeue operation removes an element from the front of the queue. In JavaScript, you can use the `shift()` method on an array to achieve this.
6+
7+
Example:
8+
9+
```javascript
10+
let queue = [1, 2, 3];
11+
let dequeued = queue.shift();
12+
console.log(dequeued); // 1
13+
console.log(queue); // [2, 3]
14+
```
15+
16+
**Tags**: [basic](./level/basic), [JavaScript](./theme/javascript), [Operations](./theme/operations)
17+
18+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
## [How do you locate elements in Protractor?](#how-to-locate-elements-in-protractor)
2+
3+
### How do you locate elements in Protractor?
4+
5+
In Protractor, you can locate elements using various locators such as CSS selectors, XPath, and Angular-specific locators.
6+
- `by.id()`: Locate by ID.
7+
- `by.css()`: Locate by CSS selectors.
8+
- `by.xpath()`: Locate by XPath.
9+
10+
Example:
11+
12+
```javascript
13+
let button = element(by.css('.submit-button'));
14+
```
15+
16+
**Tags**: [basic](./level/basic), [Protractor](./theme/protractor), [Locators](./theme/locators)
17+
18+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
## [How do you run Jest tests from the command line?](#how-do-you-run-jest-tests-from-the-command-line)
2+
3+
### How do you run Jest tests from the command line?
4+
5+
You can run Jest tests from the command line using the `jest` command. Make sure Jest is installed, and you can run `npx jest` or `npm test` to run all the tests.
6+
7+
Example:
8+
9+
```bash
10+
npx jest
11+
```
12+
13+
**Tags**: [basic](./level/basic), [Jest](./theme/jest), [Command Line](./theme/command_line)
14+
15+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
## [How do you set up Protractor for UI Testing?](#how-to-setup-protractor-for-ui-testing)
2+
3+
### How do you set up Protractor for UI Testing?
4+
5+
To set up Protractor, you need to install Node.js, install Protractor via npm, and configure the `protractor.conf.js` file. After the setup, you can use Protractor commands to interact with web pages in your tests.
6+
7+
**Tags**: [basic](./level/basic), [Protractor](./theme/protractor), [Setup](./theme/setup)
8+
9+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
## [How do you write a simple Jest test?](#how-to-write-a-simple-jest-test)
2+
3+
### How do you write a simple Jest test?
4+
5+
To write a simple Jest test, use the `test` function, which accepts a description of the test and a callback function that contains the code to test.
6+
7+
Example:
8+
9+
```javascript
10+
test('adds 1 + 2 to equal 3', () => {
11+
expect(1 + 2).toBe(3);
12+
});
13+
```
14+
15+
**Tags**: [basic](./level/basic), [Jest](./theme/jest), [Testing](./theme/testing)
16+
17+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
## [How do you write a simple Protractor test?](#how-to-write-a-simple-protractor-test)
2+
3+
### How do you write a simple Protractor test?
4+
5+
A simple Protractor test can be written by creating a `.spec.js` file that contains test cases using Jasmine or Mocha. You can then use `it()` to define the test case and `expect()` to assert conditions.
6+
7+
Example:
8+
9+
```javascript
10+
describe('Example test', () => {
11+
it('should have a title', () => {
12+
browser.get('http://example.com');
13+
expect(browser.getTitle()).toEqual('Example Domain');
14+
});
15+
});
16+
```
17+
18+
**Tags**: [basic](./level/basic), [Protractor](./theme/protractor), [Testing](./theme/testing)
19+
20+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
## [What are the basic Protractor commands?](#what-are-the-basic-protractor-commands)
2+
3+
### What are the basic Protractor commands?
4+
5+
Some of the basic Protractor commands include:
6+
- `browser.get()`: Navigate to a URL.
7+
- `element()`: Locate an element on the page.
8+
- `element(by.css())`: Locate an element using a CSS selector.
9+
- `browser.sleep()`: Pause execution for a specified time.
10+
11+
Example:
12+
13+
```javascript
14+
browser.get('http://example.com');
15+
let elem = element(by.id('username'));
16+
```
17+
18+
**Tags**: [basic](./level/basic), [Protractor](./theme/protractor), [Commands](./theme/commands)
19+
20+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
## [What are the operations on a Queue in JavaScript?](#what-are-the-operations-on-queue-in-javascript)
2+
3+
### What are the operations on a Queue in JavaScript?
4+
5+
The main operations for a queue include:
6+
- `enqueue`: Adds an element to the rear of the queue.
7+
- `dequeue`: Removes an element from the front of the queue.
8+
- `peek`: Returns the element at the front without removing it.
9+
- `isEmpty`: Checks if the queue is empty.
10+
11+
**Tags**: [basic](./level/basic), [JavaScript](./theme/javascript), [Data Structures](./theme/data_structures)
12+
13+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
## [What does the expect function do in Jest?](#what-does-the-expect-function-do-in-jest)
2+
3+
### What does the expect function do in Jest?
4+
5+
The `expect` function is used to create an assertion. It takes a value and returns an object that allows you to make assertions on that value, such as checking if it equals another value or if it meets certain conditions.
6+
7+
Example:
8+
9+
```javascript
10+
expect(2 + 2).toBe(4);
11+
```
12+
13+
**Tags**: [basic](./level/basic), [Jest](./theme/jest), [Assertions](./theme/assertions)
14+
15+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
## [What is a Queue Data Structure?](#what-is-a-queue-data-structure)
2+
3+
### What is a Queue Data Structure?
4+
5+
A queue is a linear data structure that follows the First-In-First-Out (FIFO) principle. Elements are added at the rear (enqueue operation) and removed from the front (dequeue operation). It is similar to a line at a checkout counter.
6+
7+
**Tags**: [basic](./level/basic), [JavaScript](./theme/javascript), [Data Structures](./theme/data_structures)
8+
9+

level/basic/what_is_protractor_.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
## [What is Protractor?](#what-is-protractor)
2+
3+
### What is Protractor?
4+
5+
Protractor is an end-to-end testing framework for Angular and AngularJS applications. It is built on top of WebDriverJS and allows for easy automation of browser testing, providing functionality for testing user interactions with web applications.
6+
7+
**Tags**: [basic](./level/basic), [Protractor](./theme/protractor), [UI Testing](./theme/ui_testing)
8+
9+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
## [What is the difference between a Stack and a Queue?](#what-is-the-difference-between-stack-and-queue)
2+
3+
### What is the difference between a Stack and a Queue?
4+
5+
A stack follows the Last-In-First-Out (LIFO) principle, while a queue follows the First-In-First-Out (FIFO) principle. In a stack, elements are added and removed from the same end (top), whereas in a queue, elements are added at the rear and removed from the front.
6+
7+
**Tags**: [basic](./level/basic), [JavaScript](./theme/javascript), [Data Structures](./theme/data_structures)
8+
9+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
## [What is the Jest testing framework?](#what-is-jest-framework)
2+
3+
### What is the Jest testing framework?
4+
5+
Jest is a JavaScript testing framework developed by Facebook. It is used for writing unit tests and provides a simple and easy-to-use API for writing tests for JavaScript code, particularly React applications.
6+
7+
**Tags**: [basic](./level/basic), [Jest](./theme/jest), [Testing](./theme/testing)
8+
9+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
## [How do you handle alerts in Protractor?](#how-to-handle-alerts-in-protractor)
2+
3+
### How do you handle alerts in Protractor?
4+
5+
Protractor provides methods to handle JavaScript alerts, confirms, and prompts. You can use `browser.switchTo().alert()` to switch to the alert and perform actions like accepting or dismissing it.
6+
7+
Example:
8+
9+
```javascript
10+
let alert = browser.switchTo().alert();
11+
alert.accept();
12+
```
13+
14+
**Tags**: [intermediate](./level/intermediate), [Protractor](./theme/protractor), [Alerts](./theme/alerts)
15+
16+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
## [How do you handle forms in Protractor?](#how-do-you-handle-forms-in-protractor)
2+
3+
### How do you handle forms in Protractor?
4+
5+
In Protractor, forms can be handled by interacting with form fields (input, select, etc.), filling them out, and submitting the form.
6+
7+
Example:
8+
9+
```javascript
10+
let nameField = element(by.id('name'));
11+
nameField.sendKeys('John Doe');
12+
let submitButton = element(by.id('submit'));
13+
submitButton.click();
14+
```
15+
16+
**Tags**: [intermediate](./level/intermediate), [Protractor](./theme/protractor), [Forms](./theme/forms)
17+
18+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
## [How do you handle waiting in Protractor?](#how-to-handle-waiting-in-protractor)
2+
3+
### How do you handle waiting in Protractor?
4+
5+
In Protractor, you can handle waiting using `browser.wait()` and `ExpectedConditions`. This helps wait for elements to appear, disappear, or change state before interacting with them.
6+
7+
Example:
8+
9+
```javascript
10+
let EC = protractor.ExpectedConditions;
11+
browser.wait(EC.visibilityOf(element(by.id('submit-button'))), 5000);
12+
```
13+
14+
**Tags**: [intermediate](./level/intermediate), [Protractor](./theme/protractor), [Waiting](./theme/waiting)
15+
16+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
## [How do you implement a Circular Queue in JavaScript?](#how-to-implement-circular-queue-in-javascript)
2+
3+
### How do you implement a Circular Queue in JavaScript?
4+
5+
A circular queue implementation requires maintaining two pointers (front and rear) and using modulo arithmetic to handle wraparound.
6+
7+
Example:
8+
9+
```javascript
10+
class CircularQueue {
11+
constructor(size) {
12+
this.size = size;
13+
this.queue = new Array(size);
14+
this.front = 0;
15+
this.rear = 0;
16+
}
17+
enqueue(element) {
18+
if ((this.rear + 1) % this.size === this.front) {
19+
console.log('Queue is full');
20+
} else {
21+
this.queue[this.rear] = element;
22+
this.rear = (this.rear + 1) % this.size;
23+
}
24+
}
25+
dequeue() {
26+
if (this.front === this.rear) {
27+
console.log('Queue is empty');
28+
} else {
29+
this.front = (this.front + 1) % this.size;
30+
}
31+
}
32+
peek() {
33+
return this.queue[this.front];
34+
}
35+
isEmpty() {
36+
return this.front === this.rear;
37+
}
38+
}
39+
```
40+
41+
**Tags**: [intermediate](./level/intermediate), [JavaScript](./theme/javascript), [Data Structures](./theme/data_structures)
42+
43+

0 commit comments

Comments
 (0)