Search code examples
c#seleniumtumblrbots

unclickable reblog button in tumblr (in pop up window)


so I'm trying to create a bot for tumblr, but I just can't click the reblog button (the one in the Iframe in popup post). I've searched the internet for a solution but without any luck, and now I don't know what to do. here are the methods I've tried:

IWebElement a = _driver.FindElement(By.XPath("//body[@id='search_actions_search']/div[9]/div/div/div/div/div[2]/div[2]/div/div[5]/div/div/div[3]/div/div/button"));
a.SendKeys(Keys.Enter);

then I used this one

_driver.FindElement(By.XPath("//body[@id='search_actions_search']/div[9]/div/div/div/div/div[2]/div[2]/div/div[5]/div/div/div[3]/div/div/button")).Click();

and I used also this

var jsclick3 = _driver.FindElement(By.XPath("//body[@id='search_actions_search']/div[9]/div/div/div/div/div[2]/div[2]/div/div[5]/div/div/div[3]/div/div/button"));
IJavaScriptExecutor js = _driver as IJavaScriptExecutor;
if (js != null) js.ExecuteScript("arguments[0].click();", jsclick3);

so people can anyone tell me how to get that button to be clicked!!? and thanks.


Solution

  • use implicitwait or explicitwait to wait for the webdriver to load the newly added html elements, because the dialog box was added later by javascript.

    Thread.Sleep(15000);
    //or 
    _driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10));