test cases are failed in selelinum testng

30 views
Skip to first unread message

Srikanth Reddy

unread,
Jun 25, 2021, 8:45:08 AM6/25/21
to testng-users
hi 
when i run this code on selenium it is showing failed plz help me,
this is my code
package esoft;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.interactions.Actions;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

public class esofttest {

public static WebDriver driver;
/// public static JavascriptExecutor js;

@BeforeClass
public void setUp() throws InterruptedException {


//initialization driver set property
// System.setProperty("webdriver.chrome.driver", "/home/hari/Documents/chromedriver_linux64/chromedriver");
System.setProperty("webdriver.chrome.driver", "C:\\Users\\SRIKANTH\\Downloads\\chromedriver_win32 (1) latest\\chromedriver.exe");


//driver = new FirefoxDriver();

driver = new ChromeDriver();

// Launch Website
// driver.navigate().to("http://172.20.2.23/karosoftware/index.php/");

//Maximize the browser
// driver.manage().window().maximize();

// Launch Website
driver.navigate().to("https://www.esoftech.com/");

//Maximize the browser
driver.manage().window().maximize();
Thread.sleep(3000);

String title = driver.getTitle();
System.out.println("Title is " + title);

}
@Test(priority=1, enabled=true)
public void verifybackenddeveloperpage() throws InterruptedException {

Actions actions = new Actions(driver);
WebElement menuHoverLink = driver.findElement(By.linkText("Career"));

actions.moveToElement(menuHoverLink).perform();
WebElement subLink = driver.findElement(By.xpath("//*[@id="post-1719"]/div/div[4]/div/div/div/div/div/div[7]/div/div/div[2]/div/div[2]/a"));
subLink.click();

String title = driver.getTitle();
System.out.println("Title is " + title);

}

@AfterClass
public void setDown() throws InterruptedException {
Thread.sleep(5000);

driver.close();
}

Meenesh Prasad

unread,
Jun 25, 2021, 10:45:34 AM6/25/21
to testng...@googlegroups.com
Please correct the xpath. Your xpath has double quotes as shown below error-
image.png

Either correct by removing double quotes or use beow xpath with anchor tag-


Hope it helps.
Regards,
Meenesh

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to testng-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/testng-users/d4bf0d16-5a32-4cec-a0a2-b1ad0cccd51an%40googlegroups.com.


--
Regards:
Meenesh Prasad
Mob.+91-9999257717
Reply all
Reply to author
Forward
0 new messages