Reputation: 15
Using selenium-2.44.tar.gz and chrome for automating test cases:Very strange my code works fine using Firefox 33 but fails using Google Chrome:
"WebDriverException: Message: u'unknown error: Element is not clickable at point(57, 161). Other element would receive the click: ...\n (Session info: chrome=42.0.2311.135 )\n (Driver info: chromedriver=2.9.248315,platform=Windows NT 6.1 SP1 x86_64)'" self.driver.find_element_by_xpath(".//[@id='searchMessagstoryBtn']").click()
any idea? shouldnt it work better with chrome one wonders since webdriver is Google code nowdays or am I wrong!!!
Upvotes: 0
Views: 578
Reputation: 61
@FindBy(xpath = "//[@id='searchMessagstoryBtn']")
private WebElement Search_btn;
public WebElement getSearchBtnClick() {
return Search_btn;
}
public void Click_Search_Btn() {
//click the search button
TimeUnit.SECONDS.sleep(3);
getSearchBtnClick().click();
}
Upvotes: 0
Reputation: 1417
Unlike firefox, to use chromedriver you have to download chromedriver from http://www.seleniumhq.org/download/ and had to give path in your code.
You can use the below code, to use chrome driver in java or in python
Java:
public void testGoogleSearch() {
// Optional, if not specified, WebDriver will search your path for chromedriver.
System.setProperty("webdriver.chrome.driver", "/path/to/chromedriver");
WebDriver driver = new ChromeDriver();
driver.get("http://www.google.com/xhtml");
Thread.sleep(5000); // Let the user actually see something!
WebElement searchBox = driver.findElement(By.name("q"));
searchBox.sendKeys("ChromeDriver");
searchBox.submit();
Thread.sleep(5000); // Let the user actually see something!
driver.quit();
}
Python:
import time
from selenium import webdriver
driver = webdriver.Chrome('/path/to/chromedriver') # Optional argument, if not specified will search path.
driver.get('http://www.google.com/xhtml');
time.sleep(5) # Let the user actually see something!
search_box = driver.find_element_by_name('q')
search_box.send_keys('ChromeDriver')
search_box.submit()
time.sleep(5) # Let the user actually see something!
driver.quit()
Upvotes: 1
Reputation: 84
It seems to be a bug in ChromeDriver. http://code.google.com/p/selenium/issues/detail?id=2766
Try this workaround solution from form #27. I hope it would help you:
I ran into this same issue as well with Chrome...clicking the element works fine in firefox but not in Chrome...the fix is pretty easy though, all you have to do is scroll the element into view before clicking it, and you won't run into this problem in Chrome. Here's the code i use:
IWebElement elementToClick = ;
// Scroll the browser to the element's Y position (driver as IJavaScriptExecutor).ExecuteScript(string.Format("window.scrollTo(0, {0});", elementToClick.Location.Y));
// Click the element elementToClick.Click();
Hope this helps anyone else who runs into this issue
Upvotes: 0