Skip to content

Instantly share code, notes, and snippets.

View adiralashiva8's full-sized avatar

Shiva Prasad Adirala adiralashiva8

  • Hyderabad
  • 19:00 (UTC +05:30)
View GitHub Profile
@adiralashiva8
adiralashiva8 / get_list_of_suites_with_tag.py
Last active December 4, 2024 08:16
python script to fetch list of robotframework suites which contains "regression" tag suites using get_modal(), robot api
import os
from robot.api.parsing import get_model, ModelVisitor, Token
class RobotParser(ModelVisitor):
def __init__(self, filepath):
self.filepath = filepath
self.has_smoke_tag = False
def visit_SettingSection(self, node):
@adiralashiva8
adiralashiva8 / get_deployed_server_info.py
Created November 6, 2024 04:37
ServiceNow get deployed server info
import os
import pysnow
from concurrent.futures import ThreadPoolExecutor, as_completed
import time
start = time.time()
print(f"Start time: {time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(start))}")
source_instance = 'service-now.com'
user_name = "abc"
@adiralashiva8
adiralashiva8 / get_rf_results_using_robot_results_api.py
Created October 9, 2024 05:29
Get list of suite, test and keyword details form robotframework output.xml using robotframework results api
from robot.api import ExecutionResult, ResultVisitor
from datetime import timedelta
class SuiteReportVisitor(ResultVisitor):
def __init__(self):
self.report = []
self.test_report = []
self.keyword_report = []
def visit_suite(self, suite):
@adiralashiva8
adiralashiva8 / har_analyzer.py
Last active September 12, 2024 11:30
Python script to read .har file and print respective result
# Installation:
--------------
# pip install haralyzer
# Code:
-------
import json
from haralyzer import HarParser, HarPage
with open('google.har', 'r', encoding='utf-8') as f:
@adiralashiva8
adiralashiva8 / custom_report.html
Created May 22, 2024 05:43
generate custom html report by parsing multiple output.xml in current folder, which have result stats, tag stats in report (can be used to send email by attaching html content in email body)
import os
from robot.api import ExecutionResult
from jinja2 import Template
from datetime import date
today = date.today()
now_date = today.strftime("%d-%b-%y")
# get all output.xml files in current path
output_names = []
list_of_suites = set()
@adiralashiva8
adiralashiva8 / jenkins_api_trigger_build_with_parameters.py
Last active April 20, 2024 16:08
Example to trigger Jenkins build with parameters using Jenkins API. Script will wait until job execution completed. This example to trigger same job with multiple parameters where parameter is folder name
import os
import json
from time import sleep
import multiprocessing
import requests
class BuildJob():
def __init__(self):
self.JENKINS_URL = "http://<jenkins_url>:8081"
@adiralashiva8
adiralashiva8 / startup-properties.groovy
Created April 20, 2024 16:02
Jenkins start-up script to enable images, links, javascript
# Step 1: In jenkins home directory create folder with name "init.groovy.d"
# Step 2: under above folder create file with name "startup-properties.groovy"
# Step 3: Include following code in it
import jenkins.model.Jenkins
import java.util.logging.LogManager
System.setProperty("hudson.model.DirectoryBrowserSupport.CSP", "sandbox allow-same-origin allow-popups allow-scripts; default-src *; img-src 'self' data:; style-src * http://* 'unsafe-inline' 'unsafe-eval'; script-src 'self' http://* 'unsafe-inline' 'unsafe-eval'");
@adiralashiva8
adiralashiva8 / automation_best_practices.txt
Last active June 27, 2024 06:07
Automation Best Practices
TRIMS - https://automationintesting.com/2019/08/trims-automation-in-testing-strategy.html
Few Useful Links (from gaurav talk) - https://automationhacks.io/slides/2020/se-conf/how-to-build-an-automation-framework-with-selenium/09.0-next-steps/
xpath functions: https://medium.com/@nambiarjishnu1210/xpath-functions-a078e2fccbb6
https://club.ministryoftesting.com/t/products-places-apps-and-websites-to-practice-software-testing-wiki/66651
Wiki: https://club.ministryoftesting.com/tag/wiki
@adiralashiva8
adiralashiva8 / 1.srp.py
Created February 12, 2024 10:19 — forked from dmmeteo/1.srp.py
SOLID Principles explained in Python with examples.
"""
Single Responsibility Principle
“…You had one job” — Loki to Skurge in Thor: Ragnarok
A class should have only one job.
If a class has more than one responsibility, it becomes coupled.
A change to one responsibility results to modification of the other responsibility.
"""
class Animal:
def __init__(self, name: str):