veryacademy / selenium-mastery-with-django Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
#I used the code below to test and verify the bug. 200 sec of sleep is so that I can copy and paste the url into different browser and login with admin/admin . Turns out that the django server generated by "self.live_server_url" somehow doesn't accept any credential. The reason assert pass is because the failure of login result 'admin' string stick on the username field. If one use more specific string such as 'User: admin', the test will failed on self.live_server_url. But there is no issue if we use hardcode 127.0.0.1:8000 address.
#--------------------------------------------------
class LoginFormTest(LiveServerTestCase):
def testform(self):
options = Options()
#options.headless = True
driver = webdriver.Chrome('./chromedriver')
#driver.get(('%s%s' % (self.live_server_url, '/accounts/login/')))
myvar1 = 'http://127.0.0.1:8000/accounts/login/'
myvar2 = ('%s%s' % (self.live_server_url, '/accounts/login/'))
driver.get(myvar2)
print(myvar2)
user_name = driver.find_element_by_name('username')
user_password = driver.find_element_by_name('password')
submit = driver.find_element_by_id('submit')
time.sleep(200)
user_name.send_keys('admin')
user_password.send_keys('admin')
time.sleep(1)
submit.send_keys(Keys.RETURN)
#print(driver.page_source)
print(myvar1)
assert 'User: admin' in driver.page_source
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.