0
I am trying to rewrite my script so it works using Page Object Model using Pycharm. Yes i'm an absolute newbie. So apologies if im missing something simple.
I have three questions
driver.get('http://www.demo.guru99.com/V4/') this line does not result in the page being called up in module called profile
from selenium import webdriver is greyed out in module called profile2
word 'profile' in this line is greyed out - profile = webdriver.FirefoxProfile(profile_path) why?
I would be so grateful for any guidance
profile.py module
from selenium import webdriver
import unittest
from profile2 import Login
class GuruTest(unittest.TestCase):
@classmethod
def setUpClass(self):
profile_path = 'C:/FireFoxProfile'
#looks like the word "profile = " is greyed out in line below
profile = webdriver.FirefoxProfile(profile_path)
self.driver = webdriver.Firefox(firefox_profile=profile_path)
self.driver.implicitly_wait(5)
self.driver.maximize_window()
# this should call the guru99 website with the profile defined in setup
# function and insert passwords. Website does not open why?
def Call_Login(self):
driver = self.driver
self.driver.get('http://www.demo.guru99.com/V4/')
login = Login(driver)
login,Username("mngr189426")
login.Password("hapEnyn")
login.SignIn()
@classmethod
def tearDownClass(self):
self.driver.quit()
if __name__ == '__main__':
unittest.main(verbosity=2)
Profile2.py module
#from import line is greyed out (it not in colours)
from selenium import webdriver
class Login(object):
def __init__(self, driver):
self.driver = driver
def Username(self, user_name):
self.driver.find_element_by_name("uid").clear()
self.driver.find_element_by_name("uid").send_keys(user_name)
def Password(self, password):
self.driver.find_element_by_name("password").clear()
self.driver.find_element_by_name("password").send_keys(password)
def SignIn(self):
self.driver.find_element_by_name("btnLogin").click
Ok..I figured it out.. I needed test_ before def Call_Login(self): so test_def Call_Login(self): looks like it worked. That said, if anyone can show my how to write the code better...i would love to learn – David L Levy – 2019-04-16T00:53:18.697