1

enter image description hereenter image description here org.openqa.selenium.NoSuchElementException: Unable to find element with xpath == //div[@title='Access Client Files' and @class='cpfolder normalfolder' and @id='cpfolder_2']//span[@name='modText2'] For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html

My HTML is

<div title="Access Client Files" class="cpfolder normalfolder" id="cpfolder_2" onmouseover="hoverMod(2,true)" onmouseout="hoverMod(2,false)" onclick="javascript:showMenu('Client','ORG201','PLAN','2',false)">
  <span name="modText2">Clients</span>
</div>
  • 1
    Add the corresponding HTML source in your original post, please. When using ID as a locator, you typically do not need to use other qualifiers like class and title, since the ID -should- be unique anyway, but I won't suggest an xpath until I can see some HTML code for the web element in question. – Bill Hileman Apr 16 '18 at 13:58
  • Did it work on other browsers? If you use multiple attributes together with AND operator, it will fail if it doesn't find one of them, even if others are found. Also, check this resource sqa.stackexchange.com/questions/16995/… – return Apr 16 '18 at 14:00
  • Right click on the web element that you want to find, and click Inspect Element. It will then display the code section for the the element. – return Apr 16 '18 at 14:06
  • 1
    Selenium can have issues with compound classes such as class="cpfolder normalfolder". You would be better to use only ID as a selector. – Kate Paulk Apr 16 '18 at 14:29
  • 1
    It may be inside an iframe. Again, this is something we can't tell without seeing more of the HTML – Bill Hileman Apr 16 '18 at 14:55
0

Assuming you're trying to search what is marked in your screen-shots but not what you describe in HTML snippet (because they are different elements) and assuming the frame with id="did_appframe" is the top-level frame I would recommend to try the following code:

driver.
        switchTo()
            .frame("did_appframe")
        .switchTo()
            .frame("did_cp_display")
        .findElement(By.xpath("//div[@title='Access Assignee Files']"));

This basically means that you need to "drill" to the frames one-by-one starting from the very top unless you're in the one where your target element resides.

  • Thanks Alexey, it worked. after the page loads selenium took almost 35 secs to identify the element, is there any way which i can increase the speed to identify and click on the element – RGudla Apr 19 '18 at 13:19
  • You can try different selector types. For example CSS selector. Some say CSS selectors work faster. – Alexey R. Apr 19 '18 at 13:20
2

If resetting your IE settings back to default doesn't work, I was able to solve the problem by lowering the the security level in "Internet Options" in the Internet zone from "High" to "Medium-high" or "Medium" (IE11, win10). I changed the capabilities by setting some properties for IE and it worked. Here's the code snippet:

DesiredCapabilities caps = DesiredCapabilities.internetExplorer();
caps.setCapability(InternetExplorerDriver.INITIAL_BROWSER_URL, Configuration.getConfig("My URL"));
caps.setCapability(InternetExplorerDriver.IGNORE_ZOOM_SETTING, true);
  • Hi Brian, thanks for ur help, but it has frame, and i could not identify the element. i have attached the frame code above.. – RGudla Apr 19 '18 at 12:08
0

You may use CSS selector.

 WebElement element = driver.findElement(By.cssSelector("span[name=\"modText2\"]"));
 System.out.println(element.getText()); //Should print out "Clients"
  • Hi, thanks for ur help, but it has frame, and i could not identify the element. i have attached the frame code above.. – RGudla Apr 19 '18 at 12:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.