Question

I want to click on link Requirements, i have tried below code but they are all giving error.

  1. driver.findElement(By.partialLinkText("Requirements")).click();

  2. driver.findElement(By.xpath("//a[contains(.,'Requirements')")).click();

  3. driver.findElement(By.xpath("//a[contains(text().,'Requirements')] ")).click()

  4. driver.findElement(By.xpath("//a[@href='lib/general/frmWorkArea.php?feature=reqSpecMgmt")).click();

    <frameset framespacing="0" frameborder="0" rows="70,*">
      <frame scrolling="no" noresize="noresize" name="titlebar" src="lib/general/navBar.php?tproject_id=0&tplan_id=0&updateMainPage=1">
     <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
       <html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
       <head>
       <body style="min-width: 800px;">
       <div style="float:left; height: 100%;">
      <div class="menu_title">
    
    <div class="menu_bar" style="margin: 0px 5px 0px 135px;">
    <div style="display: inline; float: right;">
    <a 1''="" tabindex="" accesskey="h" target="_parent" href="index.php">Desktop</a>
    |
     <a 2''="" tabindex="" accesskey="r" target="mainframe" href="lib/general/frmWorkArea.php?           feature=reqSpecMgmt">Requirements</a>
    |
     <a 3''="" tabindex="" accesskey="t" target="mainframe" href="lib/general/frmWorkArea.php?feature=editTc">Test Specification</a>
     </div>
    
Was it helpful?

Solution

You must switch into the frame which contains the element, before attempting to use it:

driver.switchTo().frame("titlebar");

OTHER TIPS

IWebElement frame = driver.FindElementByName("titlebar");
driver.SwitchTo().Frame(frame);

Then try to locate the required element..

Please use the following XPath value:

    driver.findElement(By.xpath("//a[@accesskey='r']")).click();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top