I have to send the string to the textfield in the webpage . I tried to access it by xpath but the xpath keeps on changing everytime I open the webpage newly. So I decided to access it using class name or tag name. But I am getting an error that the keys can not be passed to the access field.
HTML of the textfiled in the webpage:
<div class = "SearchBox">
<input aria-label = 'xyz' placeholder = 'abc'>
</div>
I tried with these lines of code but none of it is working:
text = driver.find_element_by_xpath('//div[contains(@class,'SearchBox')] and input[contains(@aria-label,'xyz')]')
text = driver.find_element_by_class_name('SearchBox')
text = driver.find_element_by_xpath("//div[@class='SearchBox']/input")
text = driver.find_element_by_xpath("//div[@class='SearchBox']/input[contains(@aria-label,'Combobox expanded. Use arrow keys to select available options or type to search.') and @dojoattachpoint='_searchInput']")
What am I doing wrong? Kindly help.
Error Log:
Traceback (most recent call last):
File "<pyshell#9>", line 1, in <module>
l.send_keys("abcdef")
File "C:\Users\Pavan-Kumar\AppData\Local\Programs\Python\Python35\lib\site-packages\selenium\webdriver\remote\webelement.py", line 479, in send_keys
'value': keys_to_typing(value)})
File "C:\Users\Pavan-Kumar\AppData\Local\Programs\Python\Python35\lib\site-packages\selenium\webdriver\remote\webelement.py", line 628, in _execute
return self._parent.execute(command, params)
File "C:\Users\Pavan-Kumar\AppData\Local\Programs\Python\Python35\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 314, in execute
self.error_handler.check_response(response)
File "C:\Users\Pavan-Kumar\AppData\Local\Programs\Python\Python35\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.ElementNotVisibleException: Message: element not visible
(Session info: chrome=65.0.3325.146)
(Driver info: chromedriver=2.38.552522 (437e6fbedfa8762dec75e2c5b3ddb86763dc9dcb),platform=Windows NT 10.0.17134 x86_64)
HTML Code Pic:
