Selenium + Python: Store text in a variable and print -


i'm trying use send_keys fill field , in same time, store value in variable. when run code, text of variable not printed.

locators.py

from selenium.webdriver.common.by import  class createnewcontractor(object):    first_name = (by.id, "id_0-first_name") 

pages.py

from locators import *  class createnewcontractor1(page):       def fill_contractor(self):          email = self.find_element(*createnewcontractor.first_name).send_keys("hello")         email.text         print email 

how can store , print text filled in email variable?

the email variable value none - send_keys() method returns.

instead, can keep text in variable:

text = "hello" self.find_element(*createnewcontractor.first_name).send_keys(text) print(text) 

or, if want value of input, use get_attribute() method:

elm = self.find_element(*createnewcontractor.first_name) elm.send_keys("hello") print(elm.get_attribute("value")) 

Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -