I am new to Selenium and trying to access and click 'Image' link on Google page, once it has searched some string. But I am unable to do this. Following is in Selenium Python:
driver = webdriver.Firefox()
driver.get ('http://google.com')
q = driver.find_element_by_xpath ("id('gbqfq')") # Search text box
q.send_keys ('Apple')
driver.find_element_by_name ('btnG').click()
# I am now going to access the 'Image' link through following comamnd
driver.find_element_by_xpath ("id('hdtb_msb')/x:div[2]/x:a").click()
Error is below:
selenium.common.exceptions.InvalidSelectorException: Message: u'The given selector id(\'hdtb_msb\')/x:div[2]/x:a is either invalid or does not result in a WebElement. The following error occurred:\nInvalidSelectorError: Unable to locate an element with the xpath expression id(\'hdtb_msb\')/x:div[2]/x:a because of the following error:\n[Exception... "An attempt was made to create or change an object in a way which is incorrect with regard to namespaces"
My questions: 1. Why is this error coming (I am using xpath Checker to get the xpath)? 2. What are other possible ways to access this link?
Thanks already!
After my research:
It looks like I have to catch the handle of the current page loaded ? Please help me, I am totally new.
x:means in XPath.