Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Send keys without specifying element in python selenium webdriver

I have a page whose source code is not available, but there is a input box where cursor is blinking.

Can i write something into the text box without finding the element. I mean, some way where send key can automatically look for focussed inputbox and type input to it.

My code does not work obviuosly

driver.send_keys("testdata") 
like image 339
Saurabh Shrivastava Avatar asked Oct 01 '15 11:10

Saurabh Shrivastava


People also ask

How do you send a key without an element?

We can send keys without specifying elements in Python with Selenium webdriver. The tagname input is used for all the edit boxes. We shall use the find_element_by_tag_name method and pass input as a parameter to that method. Thus we need not mention element attributes explicitly.

What is alternative of sendKeys in Selenium?

New Selenium IDE We can input text in the text box without the method sendKeys with thehelp of the JavaScript Executor. Selenium executes JavaScript commands with the help of the executeScript method.


1 Answers

solved it

from selenium.webdriver.common.action_chains import ActionChains actions = ActionChains(self.driver) actions.send_keys('dummydata') actions.perform() 
like image 151
Saurabh Shrivastava Avatar answered Sep 24 '22 12:09

Saurabh Shrivastava