Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
5e98a6e
Merge branch 'master' of github.com:gits5213/students2023 into selenium2
May 3, 2023
5197bef
DynamicControls
May 3, 2023
0702dad
DynamicControls
May 3, 2023
4304296
DynamicLoading
May 3, 2023
f4ba05b
EntryAdd
May 3, 2023
f786b3a
ExitIntent
May 3, 2023
2309a36
FileUploader
May 4, 2023
ce6daa2
FileUploader
May 4, 2023
f4717d6
FloatingMenu
May 4, 2023
7559f5e
Merge branch 'master' of github.com:gits5213/students2023 into selenium2
May 4, 2023
30fc7b1
BasicAuth
May 4, 2023
a3f7816
Frames
May 4, 2023
6500832
Frames
May 4, 2023
8093db4
Frames
May 4, 2023
b22b8c5
Frames
May 4, 2023
9eff06e
disappearingElements
May 4, 2023
3bc03ed
disappearingElements
May 4, 2023
4cc9122
disappearingElements
May 4, 2023
911526a
Frames
May 4, 2023
a9d607e
BrokenImages
May 5, 2023
fa716bc
Frames
May 5, 2023
fdb8fe2
Frames
May 5, 2023
d08edc0
incognito implimentation with constructor
May 6, 2023
c2753d0
HorizontalSlider
May 8, 2023
64fd872
Hovers
May 8, 2023
b36f359
InfiniteScroll
May 8, 2023
99fdd3e
alert
May 8, 2023
ba11831
Merge branch 'master' of github.com:gits5213/students2023 into selenium2
May 8, 2023
e9c40dc
alert
May 8, 2023
4b2b0bc
alert
May 8, 2023
34261fa
javaScriptAlerts
May 9, 2023
8c230d0
javaScriptAlerts
May 9, 2023
cf4cb44
JavaScriptOnLadEventError
May 9, 2023
f3b396b
keyPresses
May 9, 2023
c4ed248
multipleWindows
May 9, 2023
25164ab
multipleWindows
May 9, 2023
1bf87cf
Redirect link + status code validation
May 9, 2023
dd229e0
secure file download
May 9, 2023
c739deb
shadowDom
May 10, 2023
3f1349b
shadowDom
May 10, 2023
980182c
shadowDom
May 11, 2023
705e7f3
shadowDom
May 11, 2023
4c1fac8
SlowResources
May 12, 2023
4803278
SlowResources
May 14, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package com.theinternetherokuapp.javaSelenium.testCases.codeBackups;

import org.openqa.selenium.WebElement;

import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.net.URL;
import java.util.List;

public class BrokenImages {

public void brokenImageValidation(List<WebElement> elements){
int totalNumberOfBrokenImage = 0;
for (WebElement brokenImage : elements) {
String imageURL = brokenImage.getAttribute("src");
try{
URL url = new URL(imageURL);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setConnectTimeout(5000);
connection.connect();
if (connection.getResponseCode() != 200) {
System.out.println("Broken image found at " + imageURL + " >>> " + connection.getResponseCode() + " >>> " + connection.getResponseMessage());
totalNumberOfBrokenImage++;
}
connection.disconnect();
}
catch (IOException e){
e.printStackTrace();
}
}
System.out.println("Total number of broken images = " + totalNumberOfBrokenImage );
}

public void brokenImageValidationWithProxy(List<WebElement> elements){
int totalNumberOfBrokenImage = 0;
for (WebElement brokenImage : elements) {
String imageURL = brokenImage.getAttribute("src");
try{
Proxy proxy = new Proxy(java.net.Proxy.Type.HTTP, new InetSocketAddress("hostname", 8080));
URL url = new URL(imageURL);
HttpURLConnection connection = (HttpURLConnection) url.openConnection(proxy);
connection.setConnectTimeout(5000);
connection.connect();
if (connection.getResponseCode() != 200) {
System.out.println("Broken image found at " + imageURL + " >>> " + connection.getResponseCode() + " >>> " + connection.getResponseMessage());
totalNumberOfBrokenImage++;
}
connection.disconnect();
}
catch (IOException e){
e.printStackTrace();
}
}
System.out.println("Total number of broken images = " + totalNumberOfBrokenImage );
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package com.theinternetherokuapp.javaSelenium.testCases.codeBackups;

import org.openqa.selenium.WebElement;

import java.io.IOException;
import java.net.*;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class BrokenLinks {

public static void brokenLinks( List<WebElement> links) {

//the Set method is used to store unique value in a hash set data structure(a method to avoid duplicates)
Set<String> brokenLinkUrls = new HashSet<>();

for (WebElement link : links) {

try{
String linkURL = link.getAttribute("href");
URL url = new URL(linkURL);
HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
httpURLConnection.setConnectTimeout(5000);
httpURLConnection.connect();
if(httpURLConnection.getResponseCode() != 200)
{
brokenLinkUrls.add(linkURL + " " + httpURLConnection.getResponseCode() + httpURLConnection.getResponseMessage());
}
httpURLConnection.disconnect();
}
catch (IOException e){
e.printStackTrace();
}
}
for (String brokenLinkUrl : brokenLinkUrls) {
System.err.println(brokenLinkUrl);

}
}

// System.out.println(linkURL + " - " + httpURLConnection.getResponseMessage());
// System.err.println(linkURL + " - " + httpURLConnection.getResponseCode() + " - " + httpURLConnection.getResponseMessage());

public static void brokenLinksWithProxy( List<WebElement> links) {

//the Set method is used to store unique value in a hash set data structure(a method to avoid duplicates)
Set<String> brokenLinkUrls = new HashSet<>();

for (WebElement link : links) {

try{
String linkURL = link.getAttribute("href");
Proxy proxy = new Proxy(java.net.Proxy.Type.HTTP, new InetSocketAddress("hostname", 80));
URL url = new URL(linkURL);
HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection(proxy);
httpURLConnection.setConnectTimeout(5000);
httpURLConnection.connect();
if(httpURLConnection.getResponseCode() != 200)
{
brokenLinkUrls.add(linkURL + " " + httpURLConnection.getResponseCode() + httpURLConnection.getResponseMessage());
}
httpURLConnection.disconnect();
}
catch (IOException e){
e.printStackTrace();
}
}
for (String brokenLinkUrl : brokenLinkUrls) {
System.err.println(brokenLinkUrl);

}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.theinternetherokuapp.javaSelenium.testCases.codeBackups;

import org.openqa.selenium.WebElement;
import org.testng.Assert;

import java.io.File;
import java.util.Arrays;
import java.util.List;

public class FileCheaker {



public void checkFiles(List<WebElement> elements, String fileDirectory) {

String[] webFileList = new String[elements.size()];

for (int i = 0; i < elements.size(); i++) {
webFileList[i] = elements.get(i).getText();
}

File folder = new File(fileDirectory);
File[] allFiles = folder.listFiles();
int fileCounter = 1;

Assert.assertNotNull(allFiles);
for (File file : allFiles) {
if (Arrays.asList(webFileList).contains(file.getName())) {
System.out.println(fileCounter++ + " File : " + file.getName() + " ------- Has Been Downloaded.");
}
}

// Assert.assertNotNull(allFiles);
// for (String webFilename : webFileList) {
//
// for (File file: allFiles){
// if (file.getName().equals(webFilename)) {
// System.out.println(fileCounter++ + " File : " + webFilename + " ------- Has Been Downloaded.");
// break;
// }
// }
// }
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
package com.theinternetherokuapp.javaSelenium.testCases.codeBackups;

import org.openqa.selenium.By;
import org.openqa.selenium.Point;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

import java.awt.*;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;

public class FileUploadRobotClass {

public void uploadFileWithCoordinate(String filePath, WebElement dropArea) throws AWTException, InterruptedException {
// Click on the drop area to make it active
dropArea.click();

// Get the location of the drop area element
Point location = dropArea.getLocation();
int x = location.getX();
int y = location.getY();

// Create a Robot instance
Robot robot = new Robot();

// Move the mouse pointer to the drop area element
robot.mouseMove(x, y);

// Simulate pressing the left mouse button
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);

// Wait for a second for the drag and drop operation to start
Thread.sleep(1000);

// Simulate dragging the file to the drop area element
robot.setAutoDelay(500);
StringSelection selection = new StringSelection(filePath);
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents(selection, null);
robot.keyPress(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_V);
robot.keyRelease(KeyEvent.VK_V);
robot.keyRelease(KeyEvent.VK_CONTROL);
robot.setAutoDelay(500);

// Simulate releasing the left mouse button to drop the file
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
}

public static void uploadFile(WebDriver driver, By by, String filePath) throws AWTException, InterruptedException {
driver.findElement(by).click(); // Click on the upload button to trigger the file upload dialog

// Create a new StringSelection object with the file path
StringSelection stringSelection = new StringSelection(filePath);

// Copy the file path to the clipboard
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(stringSelection, null);

// Use Robot class to simulate keyboard events to navigate and perform file upload
Robot robot = new Robot();

// Press Enter to focus on the file upload dialog
robot.keyPress(KeyEvent.VK_ENTER);
robot.keyRelease(KeyEvent.VK_ENTER);
Thread.sleep(1000); // Sleep for a short duration to allow the file upload dialog to fully load

// Press Ctrl+V to paste the file path from the clipboard
robot.keyPress(KeyEvent.VK_CONTROL);
robot.keyPress(KeyEvent.VK_V);
robot.keyRelease(KeyEvent.VK_V);
robot.keyRelease(KeyEvent.VK_CONTROL);

Thread.sleep(1000); // Sleep for a short duration to allow the file path to be pasted

// Press Enter to perform the file upload
robot.keyPress(KeyEvent.VK_ENTER);
robot.keyRelease(KeyEvent.VK_ENTER);

Thread.sleep(1000); // Sleep for a short duration to allow the file upload to complete
}
}
2 changes: 1 addition & 1 deletion zaman/Java/theInternetHerokuap/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
target/
src/main/
pom.xml/
testng.xml/
defaultSuit.xml/

# CMake
cmake-build-*/
Expand Down
1 change: 1 addition & 0 deletions zaman/Java/theInternetHerokuap/.idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions zaman/Java/theInternetHerokuap/defaultSuit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="All Test Suite">
<test verbose="2" preserve-order="true" name="D:/SQA/practices/students2023/zaman/Java/theInternetHerokuap">
<classes>
<class name="com.app.theInternetHerokuapp.tests.LoginPage.TestInvalidPassword"/>
</classes>
</test>
</suite>
14 changes: 13 additions & 1 deletion zaman/Java/theInternetHerokuap/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
<scope>test</scope>
</dependency>


<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
Expand Down Expand Up @@ -70,6 +71,17 @@
<artifactId>poi-ooxml-schemas</artifactId>
<version>4.1.2</version>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>top.jfunc.json</groupId>
<artifactId>Json-Gson</artifactId>
<version>1.0</version>
</dependency>

</dependencies>

Expand Down Expand Up @@ -101,7 +113,7 @@
<version>2.22.1</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>testng.xml</suiteXmlFile>
<suiteXmlFile>defaultSuit.xml</suiteXmlFile>
</suiteXmlFiles>
<parallel>classes</parallel>
<threadCount>4</threadCount>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,15 @@ public ABTestingPage (WebDriver driver) {
public WebElement getAbTestingHeader() {
return abTestingHeader;
}
@FindBy(css = "html > body > div:nth-of-type(2) > div > div > h3")
public WebElement h3TestVariation;

public WebElement getH3TestVariation() {
return h3TestVariation;
}
@FindBy(css = "html > body > div:nth-of-type(2) > div > div > p")
public WebElement pAlsoKnownSplitTesting;
public WebElement getpAlsoKnownSplitTesting() {
return pAlsoKnownSplitTesting;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.app.theInternetHerokuapp.pom;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;

public class BasicAuthPage extends BasePage{
public BasicAuthPage(WebDriver driver) {
super(driver);
}

@FindBy(css = "p")
public WebElement authMessage;
public WebElement getAuthMessage() {
return authMessage;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public BrokenImagesPage(WebDriver driver) {
super(driver);
}

@FindBy(css = "div > img:nth-of-type(n)")
@FindBy(css = "img")
public List<WebElement> listOfBrokenImages;
public List<WebElement> getListOfBrokenImages() {
return listOfBrokenImages;
Expand Down
Loading