Unable to Locate Element When trying to call method from one to another

30 views
Skip to first unread message

Nabeel Sheikh

unread,
Jan 2, 2015, 8:22:04 AM1/2/15
to seleniu...@googlegroups.com
Guys,

I'm using JavaTestNG where i've two classes where i'm trying to call method from one class into another. The method in main class is coded as following :

@Test (priority=8)
// Test Activation
 public void TestActivation() {
  // System.out.println("===called==="); 
 String actual = "null";
 String expected= "null";
// Click Configuration of Pricing table link
 //driver.findElement(By.xpath("//div[@id='WC_LeftSidebarDisplay_div_2']/p[14]/a")).click();
 driver.findElement(By.linkText("Test Activation")).click();
 expected = "Test Activation";
 actual = driver.getTitle();
// Verify Title of "TestActivation" page
 Assert.assertEquals(actual,expected); 
// 1st PAC fields
 driver.findElement(By.name("PACONE"));
 driver.findElement(By.name("PACTWO"));
 driver.findElement(By.name("PACTHREE"));
//2nd PAC fields
driver.findElement(By.xpath("//div[@id='prDiv']/table/tbody/tr[2]/td/table/tbody/tr[2]/td[2]/input"));
driver.findElement(By.xpath("//div[@id='prDiv']/table/tbody/tr[2]/td/table/tbody/tr[2]/td[3]/input"));
driver.findElement(By.xpath("//div[@id='prDiv']/table/tbody/tr[2]/td/table/tbody/tr[2]/td[4]/input"));
//3rd PAC fields
driver.findElement(By.xpath("//div[@id='prDiv']/table/tbody/tr[2]/td/table/tbody/tr[3]/td[2]/input"));
driver.findElement(By.xpath("//div[@id='prDiv']/table/tbody/tr[2]/td/table/tbody/tr[3]/td[3]/input"));
driver.findElement(By.xpath("//div[@id='prDiv']/table/tbody/tr[2]/td/table/tbody/tr[3]/td[4]/input"));
//4th PAC fields
driver.findElement(By.xpath("//div[@id='prDiv']/table/tbody/tr[2]/td/table/tbody/tr[4]/td[2]/input"));
driver.findElement(By.xpath("//div[@id='prDiv']/table/tbody/tr[2]/td/table/tbody/tr[4]/td[3]/input"));
driver.findElement(By.xpath("//div[@id='prDiv']/table/tbody/tr[2]/td/table/tbody/tr[4]/td[4]/input"));
//5th PAC fields
driver.findElement(By.xpath("//div[@id='prDiv']/table/tbody/tr[2]/td/table/tbody/tr[5]/td[2]/input"));
driver.findElement(By.xpath("//div[@id='prDiv']/table/tbody/tr[2]/td/table/tbody/tr[5]/td[3]/input"));
driver.findElement(By.xpath("//div[@id='prDiv']/table/tbody/tr[2]/td/table/tbody/tr[5]/td[4]/input"));
//6th PAC fields
driver.findElement(By.xpath("//div[@id='prDiv']/table/tbody/tr[2]/td/table/tbody/tr[6]/td[2]/input"));
driver.findElement(By.xpath("//div[@id='prDiv']/table/tbody/tr[2]/td/table/tbody/tr[6]/td[3]/input"));
driver.findElement(By.xpath("//div[@id='prDiv']/table/tbody/tr[2]/td/table/tbody/tr[6]/td[4]/input"));
//7th PAC fields
driver.findElement(By.xpath("//div[@id='prDiv']/table/tbody/tr[2]/td/table/tbody/tr[7]/td[2]/input"));
driver.findElement(By.xpath("//div[@id='prDiv']/table/tbody/tr[2]/td/table/tbody/tr[7]/td[3]/input"));
driver.findElement(By.xpath("//div[@id='prDiv']/table/tbody/tr[2]/td/table/tbody/tr[7]/td[4]/input"));
//8th PAC fields
driver.findElement(By.xpath("//div[@id='prDiv']/table/tbody/tr[2]/td/table/tbody/tr[8]/td[2]/input"));
driver.findElement(By.xpath("//div[@id='prDiv']/table/tbody/tr[2]/td/table/tbody/tr[8]/td[3]/input"));
driver.findElement(By.xpath("//div[@id='prDiv']/table/tbody/tr[2]/td/table/tbody/tr[8]/td[4]/input"));
//9th PAC fields
driver.findElement(By.xpath("//div[@id='prDiv']/table/tbody/tr[2]/td/table/tbody/tr[9]/td[2]/input"));
driver.findElement(By.xpath("//div[@id='prDiv']/table/tbody/tr[2]/td/table/tbody/tr[9]/td[3]/input"));
driver.findElement(By.xpath("//div[@id='prDiv']/table/tbody/tr[2]/td/table/tbody/tr[9]/td[4]/input"));

// Select Reciever Manufacturer
new Select (driver.findElement(By.name("XUNITMETADATA"))).selectByValue("Septentrio");

//Select DGNS Service Level
new Select (driver.findElement(By.name("DGNSS_ID"))).selectByValue("Q");

//Select Beam Id's
driver.findElement(By.name("BEAM1")).click();
driver.findElement(By.name("BEAM2")).click();

//Select TimeDuration
new Select (driver.findElement(By.name("TEST_DURATION"))).selectByValue("1");

// Click date picker
 WebElement datebox = driver.findElement(By.cssSelector("img.ui-datepicker-trigger"));
 datebox.click();
 // Select highlighted date
 driver.findElement(By.className("ui-state-highlight")).click();
 
// Select Test Start Time
 new Select (driver.findElement(By.name("TEST_START_TIME"))).selectByValue("17"); 
   
// Click CheckDetails
driver.findElement(By.xpath("//div[@id='prDiv']/table/tbody/tr[3]/td/table/tbody/tr/td[3]/input"));
   } 


And following is the method of class where i'm calling the above method :

@Test(priority=2)
  public void TestActivationPartner() {
 VeriposeTestNGfile PartnerVeripose=new VeriposeTestNGfile();
 System.out.println("TestActivationCall methd called");    
 driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
 PartnerVeripose.TestActivation();


Just to add further i'm instantiating the browser separately in both classes by following method:


public class PartnerVeripose {
public static WebDriver driver = new FirefoxDriver();
    


 @BeforeTest
   public void launchBrowserPartner() {
        
   
         driver.get(baseUrl);
   }    
    
Following is the error i'm facing :

 Unable to locate element: {"method":"link text","selector":"Configuration of Commission and Partner Payments"}
Command duration or timeout: 125 milliseconds


Thanks,
Nabeel.
Reply all
Reply to author
Forward
0 new messages