-1

I am trying to Post a status in FB using selenium. But i am not able to correctly locate the Edit status text and getting NoSuchElementException. I have tried different xpaths, which are correct too but still i am getting the same exception. Please help

  • 1
    Can you list the Xpaths you tried ? – Gaurav Nov 29 '17 at 12:19
  • Please update your question with the xpath information you're trying to use and your code. There isn't enough information in this question to answer it. – Kate Paulk Nov 29 '17 at 12:42
  • Sounds like an interview/homework assignment....? I (we?) might be able and/or willing to help if you would provide more information on what you did and researched and what actually failed... – Ray Oei Nov 29 '17 at 21:33
1

For me, the checklist in a case when Selenium reports that an element is not found is:

  • Is the correct page fully loaded in the browser window, driven by Selenium?
  • Is the page in the expected state (e.g. user is logged in)?
  • Does the XPath expression work on the particular page from a manual browser instance?

As a side note: to manually determine if an XPath expression is correct, it can be verified in the browser's console (opened with Ctrl+Shift+I or F12), utilising Javascript libraries, which may already be provided by the page.

On Facebook, I tested it like this:

$x('<my xpath>')

In case the XPath is correct, it returns the found element.

To find the button for posting status, The following XPath worked for me:

//div[@data-testid='activity-sprout']

Which was verified in browser, when I executed in console the following command:

$x("//div[@data-testid='activity-sprout']")[0].click()
| improve this answer | |

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.