Skip to content

Commit 7d41df6

Browse files
committed
sonar fixes
1 parent abba05e commit 7d41df6

File tree

3 files changed

+129
-124
lines changed

3 files changed

+129
-124
lines changed

pom.xml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<project
3-
xmlns="http://maven.apache.org/POM/4.0.0"
4-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
53
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
64
<modelVersion>4.0.0</modelVersion>
75
<groupId>com.github.hemantsonu20</groupId>
86
<artifactId>selenium-sample</artifactId>
97
<version>0.0.1-SNAPSHOT</version>
108
<packaging>jar</packaging>
9+
1110
<parent>
1211
<groupId>org.springframework.boot</groupId>
1312
<artifactId>spring-boot-starter-parent</artifactId>
1413
<version>1.4.3.RELEASE</version>
1514
<relativePath />
1615
</parent>
16+
1717
<properties>
1818
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1919
<java.version>1.8</java.version>
2020
<commons.lang.version>3.0</commons.lang.version>
2121
<weddrivermanager.version>1.6.0</weddrivermanager.version>
2222
</properties>
23+
2324
<dependencies>
2425
<dependency>
2526
<groupId>org.springframework.boot</groupId>
@@ -68,6 +69,7 @@
6869
<version>${weddrivermanager.version}</version>
6970
</dependency>
7071
</dependencies>
72+
7173
<build>
7274
<plugins>
7375
<plugin>
@@ -76,4 +78,5 @@
7678
</plugin>
7779
</plugins>
7880
</build>
81+
7982
</project>
Lines changed: 83 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,83 @@
1-
package com.github.selenium;
2-
3-
import static org.junit.Assert.assertEquals;
4-
import static org.junit.Assert.assertTrue;
5-
6-
import java.util.concurrent.TimeUnit;
7-
import java.util.List;
8-
9-
import org.junit.After;
10-
import org.junit.Before;
11-
import org.junit.BeforeClass;
12-
import org.junit.Test;
13-
import org.openqa.selenium.By;
14-
import org.openqa.selenium.WebDriver;
15-
import org.openqa.selenium.WebElement;
16-
import org.openqa.selenium.chrome.ChromeDriver;
17-
18-
import io.github.bonigarcia.wdm.ChromeDriverManager;
19-
20-
public class ChromeTest {
21-
22-
private static final String BASE_PATH = "https://github.com/hemantsonu20";
23-
24-
private WebDriver driver;
25-
26-
@BeforeClass
27-
public static void loadChromeDriver() {
28-
29-
ChromeDriverManager.getInstance().setup();
30-
}
31-
32-
@Before
33-
public void setUpDriver() {
34-
35-
driver = new ChromeDriver();
36-
driver.manage().window().maximize();
37-
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
38-
}
39-
40-
@After
41-
public void tearDownDriver() {
42-
43-
driver.quit();
44-
}
45-
46-
@Test
47-
public void openGithubProfile() throws InterruptedException {
48-
49-
// open hemantsonu20's github profile
50-
driver.get(BASE_PATH);
51-
52-
// assert title of the page with full name
53-
assertEquals("hemantsonu20 (Pratapi Hemant) · GitHub", driver.getTitle());
54-
55-
// fetch fullName and username webelement
56-
WebElement fullName = driver.findElement(By.className("vcard-fullname"));
57-
WebElement userName = driver.findElement(By.className("vcard-username"));
58-
59-
// assert both elements for visibility
60-
assertTrue(fullName.isDisplayed());
61-
assertTrue(userName.isDisplayed());
62-
63-
assertEquals("Pratapi Hemant", fullName.getText());
64-
assertEquals("hemantsonu20", userName.getText());
65-
66-
// go to search box, search "hemantsonu20/selenium-sample" and submit
67-
WebElement searchBox = driver.findElement(By.className("header-search-input"));
68-
searchBox.sendKeys("hemantsonu20/selenium-sample");
69-
searchBox.submit();
70-
71-
// fetch web-element representing repo-list
72-
WebElement repoList = driver.findElement(By.className("repo-list"));
73-
74-
// fetch all <a> link tags
75-
List<WebElement> repoNames = repoList.findElements(By.tagName("a"));
76-
77-
// assert one of the repoNames "href" attribute will contain "/hemantsonu20/selenium-sample"
78-
boolean found = repoNames.stream().anyMatch(e -> e.getAttribute("href").contains("/hemantsonu20/selenium-sample"));
79-
assertTrue(found);
80-
}
81-
}
1+
package com.github.selenium;
2+
3+
import static org.junit.Assert.assertEquals;
4+
import static org.junit.Assert.assertTrue;
5+
6+
import java.util.concurrent.TimeUnit;
7+
import java.util.List;
8+
9+
import org.junit.After;
10+
import org.junit.Before;
11+
import org.junit.BeforeClass;
12+
import org.junit.Test;
13+
import org.openqa.selenium.By;
14+
import org.openqa.selenium.WebDriver;
15+
import org.openqa.selenium.WebElement;
16+
import org.openqa.selenium.chrome.ChromeDriver;
17+
18+
import io.github.bonigarcia.wdm.ChromeDriverManager;
19+
20+
public class ChromeTest {
21+
22+
private static final String BASE_PATH = "https://github.com/hemantsonu20";
23+
24+
private WebDriver driver;
25+
26+
@BeforeClass
27+
public static void loadChromeDriver() {
28+
29+
ChromeDriverManager.getInstance().setup();
30+
}
31+
32+
@Before
33+
public void setUpDriver() {
34+
35+
driver = new ChromeDriver();
36+
driver.manage().window().maximize();
37+
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
38+
}
39+
40+
@After
41+
public void tearDownDriver() {
42+
43+
driver.quit();
44+
}
45+
46+
@Test
47+
public void openGithubProfile() {
48+
49+
// open hemantsonu20's github profile
50+
driver.get(BASE_PATH);
51+
52+
// assert title of the page with full name
53+
assertEquals("hemantsonu20 (Pratapi Hemant) · GitHub", driver.getTitle());
54+
55+
// fetch fullName and username webelement
56+
WebElement fullName = driver.findElement(By.className("vcard-fullname"));
57+
WebElement userName = driver.findElement(By.className("vcard-username"));
58+
59+
// assert both elements for visibility
60+
assertTrue(fullName.isDisplayed());
61+
assertTrue(userName.isDisplayed());
62+
63+
assertEquals("Pratapi Hemant", fullName.getText());
64+
assertEquals("hemantsonu20", userName.getText());
65+
66+
// go to search box, search "hemantsonu20/selenium-sample" and submit
67+
WebElement searchBox = driver.findElement(By.className("header-search-input"));
68+
searchBox.sendKeys("hemantsonu20/selenium-sample");
69+
searchBox.submit();
70+
71+
// fetch web-element representing repo-list
72+
WebElement repoList = driver.findElement(By.className("repo-list"));
73+
74+
// fetch all <a> link tags
75+
List<WebElement> repoNames = repoList.findElements(By.tagName("a"));
76+
77+
// assert one of the repoNames "href" attribute will contain
78+
// "/hemantsonu20/selenium-sample"
79+
boolean found = repoNames.stream().anyMatch(
80+
e -> e.getAttribute("href").contains("/hemantsonu20/selenium-sample"));
81+
assertTrue(found);
82+
}
83+
}
Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,40 @@
1-
package com.github.selenium;
2-
3-
import static org.junit.Assert.assertEquals;
4-
5-
import java.util.concurrent.TimeUnit;
6-
7-
import org.junit.After;
8-
import org.junit.Before;
9-
import org.junit.Test;
10-
import org.openqa.selenium.WebDriver;
11-
import org.openqa.selenium.firefox.FirefoxDriver;
12-
13-
public class FirefoxTest {
14-
15-
private static final String BASE_PATH = "https://github.com/hemantsonu20";
16-
17-
private WebDriver driver;
18-
19-
@Before
20-
public void setUpDriver() {
21-
22-
driver = new FirefoxDriver();
23-
driver.manage().window().maximize();
24-
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
25-
}
26-
27-
@After
28-
public void tearDownDriver() {
29-
30-
driver.quit();
31-
}
32-
33-
@Test
34-
public void openFireFox() throws InterruptedException {
35-
36-
driver.get(BASE_PATH);
37-
38-
assertEquals("hemantsonu20 (Pratapi Hemant) · GitHub", driver.getTitle());
39-
}
40-
}
1+
package com.github.selenium;
2+
3+
import static org.junit.Assert.assertEquals;
4+
5+
import java.util.concurrent.TimeUnit;
6+
7+
import org.junit.After;
8+
import org.junit.Before;
9+
import org.junit.Test;
10+
import org.openqa.selenium.WebDriver;
11+
import org.openqa.selenium.firefox.FirefoxDriver;
12+
13+
public class FirefoxTest {
14+
15+
private static final String BASE_PATH = "https://github.com/hemantsonu20";
16+
17+
private WebDriver driver;
18+
19+
@Before
20+
public void setUpDriver() {
21+
22+
driver = new FirefoxDriver();
23+
driver.manage().window().maximize();
24+
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
25+
}
26+
27+
@After
28+
public void tearDownDriver() {
29+
30+
driver.quit();
31+
}
32+
33+
@Test
34+
public void openGithubProfile() {
35+
36+
driver.get(BASE_PATH);
37+
38+
assertEquals("hemantsonu20 (Pratapi Hemant) · GitHub", driver.getTitle());
39+
}
40+
}

0 commit comments

Comments
 (0)