Skip to content

rohitsheoran10/Selenium-Codes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 

Repository files navigation

Selenium-Codes

Selenium codes

Code for UdemyGenTest.java

package com.udemy.GenTests;

import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait;

public class UdemyGenTest {

@Test
public void test1() {

	WebDriver driver = new FirefoxDriver();

	driver.get("http://www.udemy.com");

	WebElement query = driver.findElement(By.linkText("Login"));

	query.click();

	// Fill Out UserName
	
	WebDriverWait wait =new WebDriverWait(driver, 4000);
	wait.until(ExpectedConditions.elementToBeClickable(By.id("id_email")));
	

	query = driver.findElement(By.id("id_email"));

	query.sendKeys("[email protected]");

	// Fill out Password

	query = driver.findElement(By.id("id_password"));

	query.sendKeys("TestBillPassword");

	// Click Login

	query = driver.findElement(By.cssSelector("input[type='submit'][value='Login']"));

	query.click();
	
	wait.until(ExpectedConditions.elementToBeClickable(By.xpath(".//*[@id='login-form']/div[1]/ul/li")));

	query = driver.findElement(By.xpath(".//*[@id='login-form']/div[1]/ul/li"));

	String errText = query.getText();
}

}

Code for the POM File:

4.0.0 com.udemy GeneralTests 0.0.1-SNAPSHOT GeneralTests General Tests for Udemy <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <junit.version>4.10</junit.version> <serenity.version>1.0.47</serenity.version> <serenity.maven.version>1.0.47</serenity.maven.version>

<dependencies>
	<dependency>
		<groupId>junit</groupId>
		<artifactId>junit</artifactId>
		<version>${junit.version}</version>
	</dependency>
	<dependency>
		<groupId>org.seleniumhq.selenium</groupId>
		<artifactId>selenium-java</artifactId>
		<version>2.52.0</version>
	</dependency>
	<dependency>
		<groupId>net.serenity-bdd</groupId>
		<artifactId>core</artifactId>
		<version>${serenity.version}</version>
	</dependency>
	<dependency>
		<groupId>net.serenity-bdd</groupId>
		<artifactId>serenity-junit</artifactId>
		<version>${serenity.version}</version>
	</dependency>

</dependencies>

<build>
	<plugins>
		<plugin>
			<groupId>org.apache.maven.plugins</groupId>
			<artifactId>maven-failsafe-plugin</artifactId>
			<version>2.19.1</version>
			<executions>
				<execution>
					<goals>
						<goal>integration-test</goal>
						<goal>verify</goal>
					</goals>
				</execution>
			</executions>
			<configuration>
				<includes>
					<include>**/*Test.java</include>
					<include>**/when*.java</include>
				</includes>
			</configuration>
		</plugin>
		<plugin>
			<groupId>org.apache.maven.plugins</groupId>
			<artifactId>maven-surefire-plugin</artifactId>
			<version>2.19.1</version>
		</plugin>
		<plugin>
			<groupId>org.apache.maven.plugins</groupId>
			<artifactId>maven-compiler-plugin</artifactId>
			<version>3.5.1</version>
			<configuration>
				<fork>true</fork>
				<executable>C:\Program Files\Java\jdk1.8.0_66\bin\javac.exe</executable>
				<!-- put your configurations here -->
			</configuration>
		</plugin>
		<plugin>
			<groupId>net.serenity-bdd.maven.plugins</groupId>
			<artifactId>serenity-maven-plugin</artifactId>
			<version>${serenity.maven.version}</version>
			<dependencies>
				<dependency>
					<groupId>net.serenity-bdd</groupId>
					<artifactId>core</artifactId>
					<version>${serenity.version}</version>
				</dependency>
			</dependencies>
			<executions>
				<execution>
					<id>serenity-reports</id>
					<phase>post-integration-test</phase>
					<goals>
						<goal>aggregate</goal>
					</goals>
				</execution>
			</executions>
		</plugin>
	</plugins>
</build>

About

Selenium codes

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published