import csv
def count_records(csv_file):
record_count = 0
first_line = None
last_line = None
# Open the CSV file and read it line by line
with open(csv_file, 'r', newline='') as file:
reader = csv.reader(file)
try:
first_line = next(reader)
for row in reader:
last_line = row
record_count += 1
except StopIteration:
pass
return record_count, first_line, last_line
# Specify the path to your CSV file
csv_file_path = 'path/to/your/file.csv'
# Count the records, get the first and last lines
num_records, first_row, last_row = count_records(csv_file_path)
# Display the results
print(f"Number of records in the CSV file: {num_records}")
print("First line:", first_row)
print("Last line:", last_row)
Bugs are happily living there and they always will, unless Computers begin to develop IQ
Thursday, October 12, 2023
Read CSV from S3
Tuesday, September 26, 2023
Kubernetes k8s
Day 3
1. INSTALLATION
kubeadm init @@will be run on master, below step will be done as a part of this command.
1. pulling images of API server, etcd, scheduler, replication controller, network proxy
2. setting ca certificate for all the above components
3. writes controller
4. start the pod of above components
5. gives user access token
6. give instruction to run kubectl cli to run.
7. gives join command to connect minion to master.
MASTER is the brain of our cluster
Following are key components in master:
- API Server
- Scheduler
- Replication Controller
- Etcd
Minion (Node)
- POD
ReplicaSets
Deployments - declaritive for replicasets and pod. Eg rollout
SERVICES: Abstract access of container and pod using kubeproxy
DAEMONSETS
JOBS
CRONJOBS
CONFIGMAP
SECRETS
NETWORK POLICY
INGRESS
Monday, September 4, 2023
Docker Commands
Day - 1
yum install docker @@ install docker
systemctl restart docker @@ restart docker
systemctl enable docker @@ autostart docker if machine restart
docker version
docker images @@ List all the images in local
docker ps @@ list the running container
docker ps -a @@ list all the container
docker run <image> @@ Starting a new container of image
docker run -i -t ubuntu /bin/bash @@ Give me interactive terminal of ubuntu image container
docker run -d smehta26/clock @@container run without log or detached
docker logs <containerId or containerName> @@print the logs
docker logs --tail 3 <containerId or containerName> @@print only 3 lines of logs
docker logs --tail 1 --follow <containerId or containerName> @@follow the logs
Starting container with user specific command
docker run -d ubuntu:14:04 sleep 1000000
Get inside the container
docker exec -it <containerId> bash
ps -eaf @@check the process once inside the container
docker exec -it <containerId> sh
Name the container
docker run -d --name c1 ubuntu:14.04 sleep 1000
docker run -d --name c2 ubuntu:14.04 sleep 1000
docker stop c1 @@graceful stop takes times
docker kill c2 @@forceful stop immediate
docker start c1
docker start c2
docker stop C1 @@Stop the container
docker start C1 - @@Start the container
docker kill C1 @@kill the container
docker rm C1 @@Remove the container
Inspect running container
docker inspect c1
Kill and remove all the running container
docker ps -q @@give only running containerId
docker ps -aq @@gives all the containerId
docker kill $(docker ps -q); docker rm $(docker ps -aq) @@kill all the running container & remove all container
CREATE YOUR OWN IMAGE:
open vi editor DockerFile and type below command
#FROM instruction is used ot define Base OS Image.
FROM ubuntu:14.04
#RUN instruction to execute command over previous step
RUN apt-get update
RUN apt-get install figlet
#CMD instruction to define default command which will run when container starts
CMD figlet zpaya
Save the editor
[root@master]# docker build -t figlet:1.0 .
[root@master]# docker images
[root@master]# docker history figlet:1.0
[root@master]# docker run figlet:1.0
[root@master]# docker ps -a --no-trunc
[root@master]# docker run figlet:1.0 figlet docker
[root@master]# docker ps -a --no-trunc
Create a image with custome file:
open vi editor Customfile and type below command
FROM ubuntu:14.04
RUN apt-get update
RUN apt-get install figlet
#ENTRYPOINT instruction is there to define default command which will run when container starts
ENTRYPOINT ["figlet"]
Save the file and build the figlet:2.0 image and start the container with the image.
COPY:
open vi editor, copy from docker host to the container
COPY Customfile /etc/
COPY Dockerfile /tmp/
Save the file and build the figlet:3.0 image and start the container with the image.
[root@master-]# docker build -t figlet:3.0 -f abc1 .
[root@master-]# docker run -it figlet:3.0 bash
root@81c9:/# cat /etc/abc
root@81c9:/# cat /tmp/Dockerfile
ENVIRONMENT VARIABLES:
vi Env
FROM ubuntu:14.04
ENV blog Blogger
ENV maven /usr/bin/mvn
ENV JAVA_HOME /usr/bin/java
CMD echo "$blog $maven $JAVA_HOME"
[root@master-]# docker build -t figlet:4.0 -f abc1 .
[root@master-]# docker run -it figlet:4.0 bash
USER INSTRUCTION:
vi UserInstruction
FROM ubuntu:14.04
RUN useradd -d "/home/zpaya" -m -s "/bin/bash" zpaya
USER zpaya
CMD id
Save the file
[root@master-]# docker build -t figlet:5.0 -f abc1 .
[root@master-]# docker run -it figlet:5.0 bash
EXPOSE PORT to INTERNET:
docker run -d -P nginx @@Expose the random port of nginx to Master node
docker run -d -p 1000:80 nginx @@Expose specified port of nginx(80) to masternode
ifconfig eth0 @@will give you the public.
http://139.xx.73.xx:1000/
Day - 2
docker push Z - upload the container
Code(Dockerfile) —>
compile(docker build) —>
DockerImage
Saturday, April 16, 2022
How to run tests in TestNg.xml using Maven
Add the below code snippet inside pom.xml file
<build>
<!-- Source directory configuration -->
<sourceDirectory>src</sourceDirectory>
<plugins>
<!-- Following plugin executes the testng tests -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<!-- Suite testng xml file to consider for test execution -->
<suiteXmlFiles>
<suiteXmlFile>testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
<!-- Compiler plugin configures the java version to be used for compiling the code -->
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
Now run from project root in command prompt or terminal
>mvn clean install
Saturday, January 15, 2022
How to use JavaScript in Google chrome Console?
HTML Code:
<ul class="multiselect-container dropdown-menu">
<li class="multiselect-item multiselect-all">
<a tabindex="0" class="multiselect-all">
<label class="checkbox">
<input type="checkbox" value="multiselect-all"
class="regular-checkbox"> Select all</label>
</a>
</li>
<li class="">
<a tabindex="0"><label class="checkbox">
<input type="checkbox" value="CANCELLED"
class="regular-checkbox"> Cancelled</label>
</a>
</li>
<li class="">
<a tabindex="0"><label class="checkbox">
<input type="checkbox" value="CONFIRMED"
class="regular-checkbox"> Confirmed</label></a></li>
<li class="">
<a tabindex="0"><label class="checkbox">
<input type="checkbox" value="REJECTED"
class="regular-checkbox"> Rejected</label>
</a>
</li>
</ul>
SOLUTION:
[
...new Set(
$x("//ul[@class='multiselect-container dropdown-menu']//a/label")
.map(value=> (
value.textContent
)
)
)
]
ANSWER:
(4) [' Select all', ' Cancelled', ' Confirmed', ' Rejected']
Sunday, November 7, 2021
Move docker-desktop-data out of Windows 10 installed drive
By default Docker Desktop will create two distros as below at %LOCALAPPDATA%/Docker/wsl
- docker-desktop
- docker-desktop-data
This folder will be used to store image and so on. Hence, its size will be increased in the future, which result in our Windows installed drive out of space. I will move it to E drive.
Below steps will move docker-desktop-data out of the Windows installed drive.
Open command prompt in Windows 10 or Powershell:
1. Stop Docker
wsl --shutdown
2. Export docker-desktop-data to tar file
wsl --export docker-desktop-data E:\docker-desktop\docker-desktop-data.tar
3. Unregister current docker-desktop-data
wsl --unregister docker-desktop-data
4. Import docker-desktop-data from tar file
wsl --import docker-desktop-data E:\docker-desktop\data E:\docker-desktop\docker-desktop-data.tar --version 2
5. Start Docker
start docker
Friday, October 22, 2021
Read Properties file using Java | Three ways
Three ways to read properties file using Java code.
1. Lazy Initialization way: Use when needed, read properties file every time.
<<<<<<<
import java.io.FileInputStream;
import java.util.Objects;
import java.util.Properties;
public final class ReadPropertyFile {
private ReadPropertyFile() {
}
public static String getValue(String key) throws Exception {
Properties property = new Properties();
FileInputStream file = new FileInputStream(System.getProperty("user.dir") + "/src/test/resources/conf/config.properties");
property.load(file);
String value = property.getProperty(key);
if (Objects.isNull(value)) {
throw new Exception("Property name " + key + " is not found. Please check the config.properties");
}
return value;
}
}
>>>>>>>
2. Eager Initialization way - Hashtable: Read properties file at start once and store it in Hashtable.
<<<<<<<
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Objects;
import java.util.Properties;
public final class ReadPropertyFile {
private ReadPropertyFile() {
}
private static Properties property = new Properties();
static {
try {
FileInputStream file = new FileInputStream(System.getProperty("user.dir")
+ "/src/test/resources/conf/config.properties");
property.load(file); //Store in java Hashtable - little slow
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
public static String getValue(String key) throws Exception {
if (Objects.isNull(property.getProperty(key)) || Objects.isNull(key)) {
throw new Exception("Property name " + key + " is not found. Please check the config.properties");
}
return property.getProperty(key);
}
}
>>>>>>>
3. Eager Initialization way - HashMap: Read properties file at start once and store it in Hashtable, then convert Hashtable into HashMap for faster operation.
<<<<<<<
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Properties;
public final class ReadPropertyFile {
private ReadPropertyFile() {
}
private static Properties property = new Properties();
private static final Map CONFIG_MAP = new HashMap<>();
static {
try {
FileInputStream file = new FileInputStream(System.getProperty("user.dir")
+ "/src/test/resources/conf/config.properties");
property.load(file); //Store in java Hashtable - little slow
// Convert Hashtable to HashMap
// Store all properties in HashMap
for (Object key : property.keySet()) {
CONFIG_MAP.put(String.valueOf(key), String.valueOf(property.get(key)));
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
public static String getValueFromMap(String key) throws Exception {
if (Objects.isNull(CONFIG_MAP.get(key)) || Objects.isNull(key)) {
throw new Exception("Property name " + key + " is not found. Please check the config.properties");
}
return CONFIG_MAP.get(key);
}
}
>>>>>>>
Thursday, July 30, 2020
How to add logger log4j in Selenium Test?
1. Add below dependency in pom.xml file:
<artifactId>log4j</artifactId>
<version>1.2.17</version>
2. Create log4j.properties file and add below content:
#File Appender
log4j.appender.FA=org.apache.log4j.FileAppender
log4j.appender.FA.File=log/AppLog.log
log4j.appender.FA.layout=org.apache.log4j.PatternLayout
log4j.appender.FA.layout.ConversionPattern=%-4r [%t] %-5p %d{dd MMM yyyy HH:mm:ss} %c %x - %m%n
#Log to Console as STDOUT
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c %3x - %m%n
#Log to file FILE
#log4j.appender.file=org.apache.log4j.DailyRollingFileAppender
#log4j.appender.file.File=logfile.log
#log4j.appender.file.DatePattern='.'yyyy-MM-dd
#log4j.appender.file.append=true
#log4j.appender.file.layout=org.apache.log4j.PatternLayout
#log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c %3x - %m%n
3. Setup and configure log4j property file in java class:
Tuesday, July 14, 2020
Cucumer settings to jump directly to step defination from feature file using Ctrl + click | Protractor Typescript
~/bdd-prj), where settings.json is placed at ~/bdd-prj/.vscode/settings.json Thursday, April 9, 2020
Paid Test Automation & Test Engineer courses FREE
Automation Specialist Level 1
Automation Specialist Level 2
Automation Engineer Level 1
Automation Engineer Level 2
Test Design Specialist Level 1
Test Design Specialist Level 2
qTest Specialist Level 1
Available till April 30
Click here to go to training page
Saturday, June 8, 2019
UiPath: UiDemo Level 3 Advance Training Assignment working code
Sunday, June 2, 2019
What does Automation Framework should have?
- Proper Exception handling
- Recovery abilities
- Effective logging
- Reporting Functionality
- High Maintainability
- Extensibility
- Reusability
- Ease of Development.
UiPath MCQ: Level 2 - Orchestrator Training
Provide you feedback under comment section -
1. Machine Templates only work for:
Active Directory users and Attended Floating Robots
2. Assets can be:
- Global
- Per Robot
3. Select only the specifications that are mandatory when deploying a process:
- The package name The package version
- The package version
- The environment
4. Where can the parameters be modified from in the Orchestrator?
- Processes -> Parameters
- Jobs -> Start Job -> Parameters
5. What happens if an active package version in Orchestrator is deleted?
Active packages cannot be deleted
6. A Robot is executing a workflow that uses the "Log Message" activity with the 'Info' level. If the log level of the robot is set to 'Error', does the Info log appear on the Orchestrator Robots > Logs page?
- No, only the log messages of type 'Error' and 'Critical' are displayed on the Orchestrator Robots > Logs page
- View all published packages
- Delete package versions
7. How can a job be initialized using Orchestrator?
- Manually, from the Jobs page
- At specific times, using Schedules
8. Which of the following data types can be stored as Assets?
- Integer
- String
- Credential
- Boolean
9. Where can you check whether a job was scheduled or manually started?
- Jobs > Source Column will have Manual or scheduler name
10. How can the processes in a schedule be assigned to the robots in a specific environment?
- Processes can run on all the robots in an environment
- Processes can run on specific robots in an environment, depending on the user's choice
11. What is the easiest way to manage the Items that were assigned to you for Review?
- By using the Review Requests Menu
12. How can a process be allocated to three different robots?
- By creating a job and selecting all three robots
- By scheduling the process and adjusting the settings in the Execution Target tab accordingly
13. How can a process that has more package versions be updated?
By going to Processes, selecting the targeted process, clicking View Versions and selecting the desired option
14. What filter types are available for Jobs?
- State
- Source
15. Which command instructs a robot to gracefully terminate the running process?
NOT THIS ONE - Stop
16. What is the mandatory field required to complete when creating a new Machine Template?
Template Name
17. There are 3 robots in the "ABC" environment. How can the execution of a package be assigned to all 3 of them?
NOT THIS ONE - By adding all 3 robots and the package in the same environment
18. What are the statuses that can be set manually for the transactions that failed due to an application exception?
NOT THIS ONE - It's not possible to set the status of any failed transaction manually
19. Which of the following Properties can be used as Filters for the Review Requests Menu?
- Priority
- Queue
- Revision
- Status
20. How are Robot Keys generated?
Orchestrator generates unique Robot Keys during the robot provisioning process
21. Can the parameters of the main workflow be inserted from the Orchestrator?
Yes
22. Can a Machine Template name be changed?
Yes, only if there are Edit rights on Machines.
23. Select the charts included in the Orchestrator Dashboard:
- Robots
- Job results
- Transactions
24. Is using the 'Publish' button in Studio the only way to upload a package to Orchestrator?
No. Packages can also be published via the Packages page in Orchestrator
25. How can you see only the jobs that ran on attended robots?
NOT THIS ONE - By selecting "Attended" from the Robot Filter in the Jobs menu.
26. Which of the steps below are required in order to establish a connection between a robot and Orchestrator?
- Provisioning the Robot in Orchestrator
- Configuring the Robot on the local machine using the Orchestrator URL and the Robot key
27. Which parameters are mandatory to be defined when creating a new environment
Name
Type
28. Which activities can be used to retrieve information from an asset
Get Asset
Get Credential
29. What are the statuses that can be set manually for the transactions that failed due to an application exception?
a). In Review
b). Retry
c).Verified
30. Where can you check whether a job was scheduled or manually started?
a). Go to the Jobs page and check the Source Column.
31. How can a job be initialized using Orchestrator ?
a).Manually, from the Jobs page
b). At specific times, using Schedules
32. What filter type are available for job?
a).State
33.Select only the specifications that are mandatory when deploying a process?
a).The Environment
b).The Package Version
c).The Package Name
34. What is Orchestrator used for?
a).Remotely controlling any number of robots and performing workflow management
35. Which of following data types can be stored as Assets?
a)Integer
b).String
c)Boolean
d)Credential
36. Which options and actions can be triggered on the Packages page?
a)View all published packages
b)Delete package versions
c)Add a new package manually
37. What happens if a new job is triggered while the robot it is assigned to is executing a different process?
a) The new job is left in a ‘Pending’ state until the robot finishes executing the process. The new job is executed as soon as the robot becomes available
38. The schedule 'stop after ' option refer to:
a). The amount of time until the schedule process will be canceled? terminate.
39. Which option can be used to stop a running process?
a)Stop
b).Kill
40. which of the steps below are required in order to establish a connection between a robot and orchestrator?
a).Provisioning the robot in Orchestrator.
b).Configuring the robot on the local machine using the orchestrator URL and Robot Key.
41. Is it possible to reprocess a transaction in a Queue after its failure due to an application exception?
a).Yes, if the Auto-Retry property of the Queue is enabled
b).Yes, it can be retried manually on the Transactions page
42. Can we set up a reviewer for the Failed Transactions?
a)YES
43. A Robot is executing a workflow that uses the “Log Message” activity, with ‘Info’ level specified. If the log level of the Robot is set to ‘Error’, will the Info log appear on the Orchestrator Log page?
a).No, only the log messages of type ‘Error’ and ‘Critical’ will be displayed on the Orchestrator Log page
44. Is it possible to check whether a Robot that is connected to Orchestrator is available or not in real time?
a).Yes, this is possible through the Heartbeat mechanism; the status of each robot is updated on the Robots page
45. How can the processes in a schedule be assigned to the robots in a specific environment?
a).Processes can run on all the robots in an environment
b).Processes can run on specific robots in an environment, depending on the user's choice.
c).Processes can run on a specific number of robots, depending on the user's choice
46. How are Robot Keys generated?
a).Orchestrator generates unique Robot Keys during the robot provisioning process
47. Which Studio activity is linked with the Stop command in Orchestrator?
a).The should stop Activity.
48. What happens if an active package version in Orchestrator is Deleted?
a). That specific Package version and all the processes using it are romoved from Orchestrator.
49. What is the easiest way to manage the item that were assigned to you for Review?
a).By using the Review Request Menu.
50. There are 3 robots in the "ABC" environment. How can the execution of a package be assigned to all 3 of them?
a).By navigating to the Processes page to pair the package with the intended environment, and then going to Jobs, selecting the intended/targeted process, and clicking Start
51. Which parameter are mandatory to be defined when creating a new Robot.
a).Name
b). Type
52. What is a transaction?
a).A set of arguments that was added to a Queue and has been processed by a robot
53. How can a process that has more package versions be updated?
a).By going to process selecting the targeted process clicking manage versions and selecting the desired option.
54.When should the add log fields activity be used?
a).When the standard log message has to be customized by adding new fields to it.
55. Select the charts included in the Orchestrator Dashboard:
a).Robot
b).job results
c). Transactions
56. What happens if the status of a Transaction is not updated within 24 hours?
a).Its status is changed to Abandoned
Saturday, May 18, 2019
UiPath MCQ (Multiple choice Question): Level 1 - Foundation Training
176. How many characters does "*" replace
zero or more
182. What activities can be used to interact with applications in a Citrix environment?
Click Image
Type Into
Click OCR Text
193. What recording wizard would you use to generate partial selectors?
Web Recording
Citrix Recording
Desktop Recording
231. What would you use to exit from a for each activity and continue the execution of the workflow?
Break activity
232. What type of content can you store inside a Generic type variable?
All
Check out Level 2 - Orchestrator Training MCQs
Read CSV from S3
import csv def count_records(csv_file): record_count = 0 first_line = None last_line = None # Open the CSV file and read it...
-
Here are the collection of UiPath MCQ question helpful in certification in UiPath RPA and interview. Check out Level 2 - Orchestrato...
-
Below Java questions I faced during my QA Automation Testing interview. Most of the answers I searched from Google, Java blogs and tutoria...
-
Get process id of all the running program on Unix or Linux system. ps ax | grep java OUTPUT: 22491 pts/0 S+ 0:00 grep --color=au...