Posts

Showing posts from August, 2022

How to do dynamic scrolling on any webpage

import io.github.bonigarcia.wdm.WebDriverManager; import org.openqa.selenium.*; import org.testng.annotations. Test ; public class ScrollDownTestAnkurDemo { @Test public static void getDynamicScrollDownByAnkur() { WebDriver driver = WebDriverManager. chromedriver ().create(); driver.manage().window().maximize(); driver.get( "https://www.google.com" ); driver.findElement(By. name ( "q" )).sendKeys( "Facebook" + Keys. ENTER ); JavascriptExecutor js = (JavascriptExecutor) driver; //Get the actual whole WebPage Height Object height = js.executeScript( "return document.body.scrollHeight" ); String ht = height.toString(); System. out .println( "Page height is : " +ht); //Calculating the Number of Steps to scroll using 450 Pixel in each scroll float htInt = Integer. parseInt (ht); System. out .println( " The number of steps to scroll

New Automation Tool : Playwright by Microsoft

 #To Initialize Playwright server : Playwright playwright = Playwright. create () #To Create Browser Instance Browser browser = playwright.chromium().launch( new BrowserType.LaunchOptions() .setHeadless( false )) ; Browser browser = playwright.firefox().launch( new BrowserType.LaunchOptions() .setHeadless( false )) ; Browser browser = playwright.webkit().launch( new BrowserType.LaunchOptions() .setHeadless( false )) ;    where setHeadLess(true or false)   # Create BrowserContext BrowserContext   browserContext  = browser.newContext()  # Create Page instance Page page = browserContext.newPage();  A Simple script: package playwrightdemo ; import com.microsoft.playwright.* ; import com.microsoft.playwright.options.* ; import static com.microsoft.playwright.assertions.PlaywrightAssertions. assertThat ; import java.nio.file.Paths ; import java.util.* ; public class test { public static void main (String[] ar

Good Website to do Automation Testing

  Good website for testing   https://the-internet.herokuapp.com/   shadowDom: https://books-pwakit.appspot.com/   https://selectorshub.com/xpath-practice-page/     For Testing Drag & drop   https://selenium08.blogspot.com/2020/01/click-and-hold.html        Learning Websites:     Selenium IDE : https://www.javacodegeeks.com/2020/06/selenium-ide-what-is-it-why-is-it-must-for-every-qa.html     Selenium GRID: Selenium 4 - Selenium Grid Modes(Standalone, Hub & Nodes and Distributed) and Grid Components     OCR:   Optical Character Recognition with EasyOCR and Python | OCR PyTorch Deep Drowsiness Detection using YOLO, Pytorch and Python

WebDriverManage ### !!! No Need to Write !!! Driver = new ChromeDriver ();

 Hi Guys With Latest Update on WebDriverManager now directly initialize you driver by hitting with version >= 5.1.1 ( as on date latest stable version is 5.2.2 ) WebDriver driver = WebDriverManager. chromedriver ().create() ;   // and for headless browsing use: ChromeOptions chromeOption = new ChromeOptions(); chromeOption.setHeadless(true); WebDriver driver = WebDriverManager.chromedriver().capabilities(chromeOption).create();  

CI-CD

  JDK - COnfig Jfrog - + Local repo - Select MAVEN - Repository Key ( from POM.xml <repostory>.<name> )     During cicd pipeline:   PIPELINE: Setup   -   Compile   -    StaticAnalysis   -   UnitTest   -   CodeCoverage   -   War         -   ToArtifactary   -   SmokeTest Mvn config: Clean   -   compile   -     sonar:sonar      -   test           -   jacoco:report     -   war:war -   deploy        target/sure-fire/*.xml Publish Jacoco coverage report + target/.../coverage.xml Deploy war/ear to the server -   */*.war   ,   /com.ms.calc, AddContainer- TOMCAT9 Setup - build-3, Days-2,PollSCM- H/2 * * * *, Git/MavenProject details (from INDEX Page .git ) + check Branch, Delete, (pre build) InvokeTopLevel-MyMaven, clean, (post Build)-Achieve-**/*, next - Compile   Compile - build-3, Days-2,Delete (pre build) Prev-Setup   **/*, InvokeTopLevel-MyMaven- compile, (post Build)-Achieve-**/*, next - StaticAnalysis   Stat

How to Scan and Identify an Object

USE JUPYTER NOTEBOOK   pip install torch torchvision torchaudio  !git clone https://github.com/ultralytics/yolov5 !cd yolov5 pip install -r requirements.txt   import torch from matplotlib import pyplot as plt import numpy as np import cv2 model = (torch.hub.load('ultralytics/yolov5','yolov5s')) model   img = '//Users//Documents//NewTest//ScanProject//image1.png'  results = model(img) results.print() matplotlib inline plt.imshow(np.squeeze(results.render())) plt.show()  results.show() # cap = cv2.VideoCapture(0) #from machine library then use below: cap = cv2.VideoCapture('/Users/Documents/NewTest/resources/DemoVideo.mov') while cap.isOpened():     ret, frame = cap.read()          #make detection     results = model(frame)          cv2.imshow('YOLO',np.squeeze(results.render()))          if cv2.waitKey(10) & 0xFF == ord('q'):         break cap.release() cv2.destroyAllWindows()  

How to Scan a Text From the IMAGE

Image
 Python Project to run from cmd python className.py import easyocr import cv2 from matplotlib import pyplot as plt import numpy as np #gets Picture input from ScanProject (java) project IMAGE_PATH = "//Users//Documents//NewTest//ScanProject//image1.png" reader = easyocr.Reader([ 'en' ] , gpu = False ) result = reader.readtext(IMAGE_PATH) print (result) top_left = tuple (result[ 0 ][ 0 ][ 0 ]) bottom_right = tuple (result[ 0 ][ 0 ][ 2 ]) text = result[ 0 ][ 1 ] print ( "The text is :" +text) #To print the image font = cv2.FONT_HERSHEY_SIMPLEX img = cv2.imread(IMAGE_PATH) img = cv2.rectangle(img , top_left , bottom_right , ( 0 , 255 , 0 ) , 2 ) # img = cv2.putText(img,text,top_left,font,0.5,(255,0,0),1,cv2.LINE_AA) plt.figure( figsize =( 10 , 10 )) plt.imshow(img) plt.show() # To show details on multiple text # img = cv2.imread(IMAGE_PATH) # for detection in result: # top_right = tuple([int(val) for val in detection[0][0]]) # bottom_right = tuple([int