0

enter image description here

Getting no such element: Unable to locate element error when writing with XPath or CSS. Please help

diver.findElement(By.cssSelector("ticket-title-input")).sendKeys("hello");

4 Answers 4

1

Try using any of the following Xpaths,

//input[@id='ticket-title-input']
//div[@id='ticket-title-panel']//following-sibling::input
//div/following::input[@id='ticket-title-input']
3
  • Hi Shanilla thanks for your help. I tried with all the above options but still getting Unable to locate error. Any suggestions on this please?
    – anonymous
    Commented Jun 27, 2018 at 15:17
  • Can you please share the error which you are getting and the code which you have tried.
    – shanila
    Commented Jun 27, 2018 at 16:10
  • @anonymous check weather the element present inside the iframe
    – Vel Guru
    Commented Jun 28, 2018 at 6:07
0

Try

diver.findElement(By.cssSelector("#ticket-title-input")).sendKeys("hello");

# means you take element with id. Check this post for details.

1
  • Hi Alexey thanks for your help. I tried with the above but still getting Unable to locate error. Any suggestions on this please?
    – anonymous
    Commented Jun 27, 2018 at 15:18
0

As guessed, the element is present inside a frame.

  1. Please switch to the frame with below xpath.

    //iframe[@src = 'vcr/1404/Pages/newTicketV2.html']

Pass the instance of web element of the iframe above as argument to the

driver.switchTo().frame(_element);
  1. Then perform the interaction with the intended element

    //input[@id = 'ticket-title-input']

  2. After the interaction is over and when you think you dont have interact with any other element inside that frame, switch to default content

0

enter image description hereI believe that the element is present inside a frame, had a look at the top-most html line. I would suggest,

  • find out the frame container of this element
  • Switch to that frame and perform operation on that element.
  • Switch back to the parent context

Hope this helps. Please share the entire html for better response.

1
  • I have added the HTML screenshot above.Please let me know how to handle Frames here. Thanks in advance Kshetra Mohan Prusty
    – anonymous
    Commented Jun 28, 2018 at 17:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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