0

Please help,

I use C#, selenium web driver 3.141 and selenium firefox web driver 0.22 to do my job.

I want to click see more button/link on facebook liker list page (example page: https://www.facebook.com/ufi/reaction/profile/browser/?ft_ent_identifier=917471895105237&av=100027618912502)

I have successfully found the xpath from the see more button/link but unable to click on it. I've tried a number of these things but still haven't succeeded either.

click on link dirrectly

var elMoreLiker = driver.FindElement(By.XPath("//a[contains(@class,'uiMorePagerPrimary')]"));
elMoreLiker.Click();
System.Threading.Thread.Sleep(3000);

click on link parent

var elMoreLiker = driver.FindElement(By.XPath("//a[contains(@class,'uiMorePagerPrimary')]"));
elMoreLiker = elMoreLiker.FindElement(By.XPath(".."));
elMoreLiker.Click();
System.Threading.Thread.Sleep(3000);

click on link parent of parent

var elMoreLiker = driver.FindElement(By.XPath("//a[contains(@class,'uiMorePagerPrimary')]"));
elMoreLiker = elMoreLiker.FindElement(By.XPath(".."));
elMoreLiker = elMoreLiker.FindElement(By.XPath(".."));
elMoreLiker.Click();
System.Threading.Thread.Sleep(3000);

using javascript to perform click (have tried clicking to the parent too)

var elMoreLiker =   driver.FindElement(By.XPath("//a[contains(@class,'uiMorePagerPrimary')]"));
IJavaScriptExecutor js = (IJavaScriptExecutor)driver;
js.ExecuteScript("arguments[0].click();", elMoreLiker);
System.Threading.Thread.Sleep(3000);

using enter to perform click (have tried clicking to the parent too)

var elMoreLiker =   driver.FindElement(By.XPath("//a[contains(@class,'uiMorePagerPrimary')]"));
elMoreLiker.SendKeys(OpenQA.Selenium.Keys.Enter);
System.Threading.Thread.Sleep(3000);

using action to perform click

var elMoreLiker =   driver.FindElement(By.XPath("//a[contains(@class,'uiMorePagerPrimary')]"));
Actions ayo = new Actions(driver);
ayo.MoveToElement(elMoreLiker).Click().Build().Perform();
System.Threading.Thread.Sleep(3000);

I've been stuck here for a few days and have no clue anymore what should i try. Any help will be appreciated.

herahadi
  • 11
  • 4
  • it's interesting that all ways are doing the same, repeating the same mistake over and over: `Thread.Sleep` (never a good option) and `FindElement` (instead of waiting for it). Please invest about 30 min into learning [basics of selenium](http://toolsqa.com/selenium-webdriver/wait-commands/) before asking – timbre timbre Nov 03 '18 at 06:27
  • Thread.Sleep on that code is just to make sure that my click is performed. just ignore my thread.sleep coding then and focus on the problem, do you have any advice why my click didn't work?? – herahadi Nov 03 '18 at 09:34
  • Well, I gave you a direction of one improvement that is good regardless of anything else: wait for element instead of finding it. But since you didn't provide anything before the non-working piece of code, and you didn't really specify what " unable to click on it" means (are you getting an exception, or button is not clicked, or is clicked, but nothing happens, etc), it's hard to help, can be many things (this is why you are not getting any answers). – timbre timbre Nov 04 '18 at 20:11
  • in addition to waiting, you may need to scroll button into view: https://stackoverflow.com/questions/3401343/scroll-element-into-view-with-selenium – timbre timbre Nov 04 '18 at 20:12

0 Answers0