Selenium Chromedriver download profile - python

i usually use the following function to set profile for Firefox
def FirefoxProfile(path, handlers):
debug = True
if debug: print "%r - %s(%r, %r)" % (time.asctime(), "FirefoxProfile", path, handlers)
profile = webdriver.FirefoxProfile()
profile.set_preference("browser.download.manager.showWhenStarting",False)
if (not(isfile(path)) & exists(path)):
profile.set_preference("browser.download.folderList",2)
profile.set_preference("browser.download.dir", path)
profile.set_preference("browser.download.downloadDir", path)
profile.set_preference("browser.download.defaultFolder", path)
else:
profile.set_preference("browser.download.folderList",1)
profile.set_preference("browser.helperApps.alwaysAsk.force", False)
profile.set_preference("browser.helperApps.neverAsk.saveToDisk", handlers)
profile.set_preference("pdfjs.disabled", True)
profile.update_preferences()
if debug: print "done. - %r" % time.asctime()
return profile
# Somewhere else
self.profile = PyWebBot.FirefoxProfile(config['downloads'], config['handlers'])
self.driver = webdriver.Firefox(self.profile)
how to do this for Chrome ? i need the same settings
Save file to custom directory
Autosave (never ask)
Edit
def Google_desired_capabilities(path=os.getcwd()):
return {"prefs": {
"download.default_directory": path,
"download.prompt_for_download": False
},
"switches": ["-silent", "--disable-logging"],
"chromeOptions": {
"args": ["-silent", "--disable-logging"]
}
}
Update
chrome_options = webdriver.ChromeOptions()
chrome_options.prefs = PyWebBot.Google_desired_capabilities(config['downloads'])['prefs']
self.driver = webdriver.Chrome(path.join(config['drivers'],'chromedriver.exe'), chrome_options=chrome_options)

Related

Firefox processes not ending when django tests which use selenium are done running, even after driver.quit()

Here's some relevant code:
class PpeLiveTest(LiveServerTestCase):
def test_algamoil_incentives_table_total(self):
options = webdriver.FirefoxOptions()
options.add_argument("--headless")
driver = webdriver.Firefox(options=options)
driver.get('https://dev.redacted.com/pr-run-ppe?group=AL%2FGA%2FMO%2FIL&check_date=05%2F05%2F2022')
# login first
username_element = driver.find_element_by_id('id_login')
username_element.send_keys('mjohnson#doozer.com')
password_element = driver.find_element_by_id('id_password')
password_element.send_keys(os.environ.get('ADMIN_PASS'))
login_button = driver.find_element_by_xpath('/html/body/div/div/div/form/button')
login_button.click()
incentives_table = driver.find_elements_by_css_selector('#incentives-table > tbody')[0]
georgia_row = incentives_table.find_elements_by_css_selector('tr')[4]
georgia_total_cell = georgia_row.find_elements_by_css_selector('td')[2]
alabama_row = incentives_table.find_elements_by_css_selector('tr')[12]
alabama_total_cell = alabama_row.find_elements_by_css_selector('td')[2]
missouri_row = incentives_table.find_elements_by_css_selector('tr')[16]
missouri_total_cell = missouri_row.find_elements_by_css_selector('td')[2]
illinois_row = incentives_table.find_elements_by_css_selector('tr')[21]
illinois_total_cell = illinois_row.find_elements_by_css_selector('td')[2]
total_row = incentives_table.find_elements_by_css_selector('tr')[22]
total_cell = total_row.find_elements_by_css_selector('td')[2]
algamoil_sum = (
int(georgia_total_cell.text.replace(',', '')) +
int(alabama_total_cell.text.replace(',', '')) +
int(missouri_total_cell.text.replace(',','')) +
int(illinois_total_cell.text.replace(',',''))
)
total_cell_value = int(total_cell.text.replace(',',''))
driver.quit()
self.assertEqual(total_cell_value, algamoil_sum)
As you can see, driver.quit() is at the end of this test, but after each test (this is one of 6 like it), the firefox processes stay running. Why?
Any help is appreciated, thanks in advance.

handshake failed; returned -1, ssl error code 1, net_error -202

I am trying to add an auth proxy on each browser window that i open up using user input but i get these errors...
[20792:21516:1222/011708.284:ERROR:ssl_client_socket_impl.cc(935)] handshake failed; returned -1, SSL error code 1, net_error -202
DEBUG:seleniumwire.proxy.handler:accounts.google.com:443 200
I have logging enabled and i'm seeing that i'm not even using the proxy i imported from my .txt file based on the log it gives...
7.0.0.1:50988", "noProxy": ""}, "acceptInsecureCerts": true}}, "desiredCapabilities": {"browserName": "chrome", "version": "", "platform": "ANY", "proxy": {"proxyType": "manual", "httpProxy": "127.0.0.1:50988", "sslProxy": "127.0.0.1:50988", "noProxy": ""}, "acceptIns
ecureCerts": true}}
For instance, if the user inputs 1, then 1 window with a proxy from the proxy list, "proxies.txt," will be opened up.
Here is my full code.
from seleniumwire import webdriver
from selenium.webdriver.chrome.options import Options
import logging
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from fake_useragent import UserAgent
import time
import random
from bs4 import BeautifulSoup
logging.basicConfig(level=logging.DEBUG)
chrome_path = r"chromedriver.exe"
times = ""
start_page = ""
settings = Options()
# proxy = Proxy()
pro_sheet = open("proxies.txt", "r")
new_proxy = []
for line in pro_sheet:
new_proxy.append(line)
def start_pages(target_page):
new = []
ip = ''
port = ''
username = ''
password = ''
j = 0
for x in range(0, len(page_number)):
j = j + 1
time.sleep(3)
print("Attempting to add fake userAgent...")
ua = UserAgent()
user_agent = ua.random
print("Successfully added fake userAgent...")
time.sleep(1)
print("Attempting to add capabilities and chrome options...")
settings.add_argument(f'user-agent={user_agent}')
settings.add_experimental_option("detach", True)
settings.add_argument("window-size=600,600")
settings.add_argument('--disable-extensions')
settings.add_argument('--profile-directory=Default')
settings.add_argument("--disable-plugins-discovery")
settings.add_argument("--proxy-server=%s" % random.choice(*new_proxy))
settings.add_argument("ignore-certificate-errors-spki-list")
print("Successfully added chrome arguments and capabilities/options...")
print("Attempting to detach chrome...")
settings.add_experimental_option("detach", True)
print("Successfully Detached chrome...")
time.sleep(1)
# print("Attempting to to initiate headless mode")
# chrome_options.add_argument("--headless")
# print('Initiated headless mode')
print("Attempting to add proxy...")
time.sleep(1)
for p in range(len(new_proxy)):
new = new_proxy[p]
# print(new)
n_p = new.split(':')
for b in range(0, len(n_p)):
ip = n_p[0]
port = n_p[1]
username = n_p[2]
password = n_p[3]
options = {
'proxy': {
'http': ip + ':' + port + ':' + username + ':' + password,
'https': ip + ':' + port + ':' + username + ':' + password,
}
}
driver = webdriver.Chrome(chrome_path, seleniumwire_options=options)
driver.set_window_position(0, 0)
time.sleep(1)
print("Successfully added proxy...")
print("Browser number " + str(j) + ", is using proxy: " + str(*new_proxy))
time.sleep(1)
print("Browser number " + str(j) + " has opened successfully...")
while times == "":
times = input("How many pages do you want?\n")
# url = input("Yeezy Supply or Adidas?""\nEither 'YS' or 'Adidas'\n")
# url_choice = url.lower()
page_number = list()
for i in range(0, int(times)):
page_number.append(times)
# if url_choice == 'ys':
# start_page = 'https://yeezysupply.com/'
# start_pages(start_page)
# elif url_choice == 'adidas':
# start_page = 'https://www.adidas.com/yeezy'
# start_pages(start_page)
start_page: str = 'https://www.adidas.com/yeezy'
start_pages(start_page)
I got the same error code when i was making an Android app to display my self signed website in a webview.
[ERROR:ssl_client_socket_impl.cc(935)] handshake failed; returned -1, SSL error code 1, net_error -202
This link solved my problem maybe it could help you?
SLL ERROR FIX
private X509Certificate[] mCertificates;
private PrivateKey mPrivateKey;
private void loadCertificateAndPrivateKey() {
try {
InputStream certificateFileStream = getClass().getResourceAsStream("/assets/cert.pfx");
KeyStore keyStore = KeyStore.getInstance("PKCS12");
String password = "password";
keyStore.load(certificateFileStream, password != null ? password.toCharArray() : null);
Enumeration<String> aliases = keyStore.aliases();
String alias = aliases.nextElement();
Key key = keyStore.getKey(alias, password.toCharArray());
if (key instanceof PrivateKey) {
mPrivateKey = (PrivateKey)key;
Certificate cert = keyStore.getCertificate(alias);
mCertificates = new X509Certificate[1];
mCertificates[0] = (X509Certificate)cert;
}
certificateFileStream.close();
} catch (Exception e) {
Log.e(TAG, e.getMessage());
}
}
private WebViewClient mWebViewClient = new WebViewClient() {
#Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return false;
}
#Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
handler.proceed();
}
#Override
public void onReceivedClientCertRequest(WebView view, final ClientCertRequest request) {
if (mCertificates == null || mPrivateKey == null) {
loadCertificateAndPrivateKey();
}
request.proceed(mPrivateKey, mCertificates);
}
};

Python Selenium Printing Save-As-PDF Waiting for Filename Input

I'm trying to save a website as PDF through printing dialog. My code allows me to save as pdf, but asks me to input a filename, which I don't know how to pass a filename to the pop up box.
Attached is my code:
import time
from selenium import webdriver
import os
class printing_browser(object):
def __init__(self):
self.profile = webdriver.FirefoxProfile()
self.profile.set_preference("services.sync.prefs.sync.browser.download.manager.showWhenStarting", False)
self.profile.set_preference("pdfjs.disabled", True)
self.profile.set_preference("print.always_print_silent", True)
self.profile.set_preference("print.show_print_progress", False)
self.profile.set_preference("browser.download.show_plugins_in_list",False)
foxdriver = r'C:\Users\AShen\Documents\Workspace\geckodriver.exe'
self.driver = webdriver.Firefox(executable_path=foxdriver,firefox_profile = self.profile)
time.sleep(5)
def get_page_and_print(self, page):
self.driver.get(page)
time.sleep(5)
self.driver.execute_script("window.print();")
if __name__ == "__main__":
browser_that_prints = printing_browser()
browser_that_prints.get_page_and_print('http://www.google.com/')
These days I had the same question.
I solved it without using the pyautogui in these case, because I use different PCs and monitors and I didn't want to depend on the position of the click.
I was able to solve it using the about:config... changing them with each necessary print (in PDF).
The name of my printer "in PDF" in Ubuntu is "Print to File" (defined in print_printer) and the settings of about:config need to be this printer...
For example: print.printer_Print_to_File.print_to_file: true
import os
import time
from selenium import webdriver
class printing_browser(object):
def __init__(self):
self.profile = webdriver.FirefoxProfile()
self.profile.set_preference('services.sync.prefs.sync.browser.download.manager.showWhenStarting', False)
self.profile.set_preference('pdfjs.disabled', True)
self.profile.set_preference('print.always_print_silent', True)
self.profile.set_preference('print.show_print_progress', False)
self.profile.set_preference('browser.download.show_plugins_in_list', False)
self.profile.set_preference('browser.download.folderList', 2)
self.profile.set_preference('browser.download.dir', '')
self.profile.set_preference('browser.download.manager.showWhenStarting', False)
self.profile.set_preference('browser.aboutConfig.showWarning', False)
self.profile.set_preference('print.print_headerright', '')
self.profile.set_preference('print.print_headercenter', '')
self.profile.set_preference('print.print_headerleft', '')
self.profile.set_preference('print.print_footerright', '')
self.profile.set_preference('print.print_footercenter', '')
self.profile.set_preference('print.print_footerleft', '')
self.profile.set_preference('browser.helperApps.neverAsk.saveToDisk', 'application/octet-stream;application/vnd.ms-excel;text/html')
foxdriver = r'C:\Users\AShen\Documents\Workspace\geckodriver.exe'
self.driver = webdriver.Firefox(
executable_path=foxdriver,
firefox_profile=self.profile
)
time.sleep(1)
def get_page_and_print(self, page, filepath):
# Get about:config
self.driver.get('about:config')
time.sleep(1)
# Define Configurations
script = """
var prefs = Components.classes['#mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
prefs.setBoolPref('print.always_print_silent', true);
prefs.setCharPref('print_printer', 'Print to File');
prefs.setBoolPref('print.printer_Print_to_File.print_to_file', true);
prefs.setCharPref('print.printer_Print_to_File.print_to_filename', '{}');
prefs.setBoolPref('print.printer_Print_to_File.show_print_progress', true);
""".format(filepath)
# Set Configurations
self.driver.execute_script(script)
time.sleep(1)
# Get site to print in pdf
self.driver.get(page)
time.sleep(2)
self.driver.execute_script("window.print();")
browser_that_prints = printing_browser()
browser_that_prints.get_page_and_print('http://www.google.com', os.path.join(os.getcwd(), 'mywebpage.pdf'))
Oh, it is very easy if you know about pyautogui.
This is an amazing module that allows you to automate your curser.
So essentially, you need to figure out the place where the popup appears and use pyautogui to click it for you.
All you need to add is:
time.sleep(3)
i=random.randint(0,1000)
file_name=('name_pdf '+str(i))
print (file_name)
pyautogui.typewrite(file_name)
pyautogui.click(512,449)
Entire code structure will look like this:
import time
import pyautogui
from selenium import webdriver
import os
class printing_browser(object):
def __init__(self):
self.profile = webdriver.FirefoxProfile()
self.profile.set_preference("services.sync.prefs.sync.browser.download.manager.showWhenStarting", False)
self.profile.set_preference("pdfjs.disabled", True)
self.profile.set_preference("print.always_print_silent", True)
self.profile.set_preference("print.show_print_progress", False)
self.profile.set_preference("browser.download.show_plugins_in_list",False)
foxdriver = r'C:\Users\Pranjal Pathak\Desktop\Titanic Kaggle\geckodriver.exe'
self.driver = webdriver.Firefox(executable_path=foxdriver,firefox_profile = self.profile)
time.sleep(5)
def get_page_and_print(self, page):
self.driver.get(page)
time.sleep(5)
self.driver.execute_script("window.print();")
if __name__ == "__main__":
browser_that_prints = printing_browser()
browser_that_prints.get_page_and_print('http://www.python.org/')
time.sleep(3)
i=random.randint(0,1000)
file_name=('name_pdf '+str(i))
print (file_name)
pyautogui.typewrite(file_name)
pyautogui.click(512,449)
Note: 1. I have selected the name of the file as name+any random integer between 1 to 1000 to change name every time you save the file. This way it will save every time you run the code as the names will be different every time.
If this types the name but does not save the file, you might want to change the coordinates of your curser. Let me know if that happens.

python selenium im getting an multiple errors in my class?

I'm new to Python, and I'm trying to modify SeleniumLibrary from robotframwork to meet my own needs. Unfortunately,l I'm getting multiple errors and I don't know why.
There are multiple functions to call different browsers with binary path and headless option.
import os
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
DEFAULT_BROWSR = 'chrome'
DRIVERS_PATH = os.path.join( os.getcwd() , "\drivers\\" )
BROWSER_NAMES = {
'ff': "_make_ff",
'firefox': "_make_ff",
'headlessfirefox': '_make_headless_ff',
'gc': "_make_chrome",
'googlechrome': "_make_chrome",
'headlesschrome': '_make_headless_chrome',
'chrome': "_make_chrome",
}
BROWSER_PATHS = {
'_make_ff': "geckodriver-win32\geckodriver.exe",
'_make_headless_ff': "geckodriver-win32\geckodriver.exe",
'_make_chrome': "chromedriver_win32\chromedriver.exe",
'_make_headless_chrome': "chromedriver_win32\chromedriver.exe",
}
class driver(object):
"""docstring for driver"""
def __init__(self):
self.driver = None
self.driver_path = None
self.timeout = 20
self.implicit_wait = 5
def create(self,browser_name=DEFAULT_BROWSR):
return self._make_driver(browser_name)
def _make_driver(self, browser_name, desired_capabilities=None, profile_dir=None, remote=None):
creation_func = self._get_driver_creation_function(browser_name)
driver_path = self._get_driver_path(browser_name)
desired_capabilities = {"chrome.binary": driver_path,}
driver = creation_func(remote, desired_capabilities, profile_dir)
driver.set_script_timeout(self.timeout)
driver.implicitly_wait(self.implicit_wait)
return driver
""" Return browser function name """
def _get_driver_creation_function(self,browser_name):
try:
func_name = BROWSER_NAMES[browser_name]
except KeyError:
raise ValueError(browser_name + " is not a supported browser.")
return getattr(self, func_name)
""" Return browser driver path """
def _get_driver_path(self,browser_name):
try:
func_name = self._get_driver_creation_function(browser_name)
driver_path = os.path.join(DRIVERS_PATH , BROWSER_PATHS[func_name])
except KeyError:
raise ValueError(browser_name + " is not a supported browser.")
return getattr(self, driver_path)
""" Used inside driver creation functions """
def _generic_make_driver(self, webdriver_type, desired_cap_type, remote_url, desired_caps, options=None):
if is_falsy(remote_url):
if options is None:
driver = webdriver_type()
else:
driver = webdriver_type(options=options)
else:
driver = self._create_remote_web_driver(desired_cap_type, remote_url, desired_caps, options=options)
return driver
def _create_remote_web_driver(self, capabilities_type, remote_url, desired_capabilities=None, profile=None, options=None):
desired_capabilities_object = capabilities_type.copy()
if not isinstance(desired_capabilities, dict):
desired_capabilities = self._parse_capabilities_string(desired_capabilities)
desired_capabilities_object.update(desired_capabilities or {})
return webdriver.Remote(desired_capabilities=desired_capabilities_object,
command_executor=str(remote_url), browser_profile=profile,
options=options)
def _make_ff(self, remote, desired_capabilities, profile_dir, options=None):
if is_falsy(profile_dir):
profile = webdriver.FirefoxProfile()
else:
profile = webdriver.FirefoxProfile(profile_dir)
if is_truthy(remote):
driver = self._create_remote_web_driver(webdriver.DesiredCapabilities.FIREFOX, remote,
desired_capabilities, profile, options=options)
else:
driver = webdriver.Firefox(firefox_profile=profile, options=options, **self._geckodriver_log_config)
return driver
def _make_headless_ff(self, remote, desired_capabilities, profile_dir):
options = webdriver.FirefoxOptions()
options.set_headless()
return self._make_ff(remote, desired_capabilities, profile_dir, options=options)
def _make_chrome(self, remote, desired_capabilities, profile_dir, options=None):
return self._generic_make_driver(
webdriver.Chrome, webdriver.DesiredCapabilities.CHROME, remote,
desired_capabilities, options=options)
def _make_headless_chrome(self, remote, desired_capabilities, profile_dir):
options = webdriver.ChromeOptions()
options.set_headless()
return self._make_chrome(remote, desired_capabilities, profile_dir, options)
This function should open a browser which will call the default chrome driver:
driver().create()
As highlighted in the comments, this kind of issues can be easily resolved by using a properly configured Python IDE with debugging capabilities. There are several good ones, both open source and commercial.
In this particular case your script has two problems:
Missing Import:
from robot.utils import is_falsy
Function that needs a bit of rewriting as the func_name needs to be a different value.
""" Return browser driver path """
def _get_driver_path(self,browser_name):
try:
#func_name = self._get_driver_creation_function(browser_name)
driver_path = os.path.join(DRIVERS_PATH , BROWSER_PATHS[BROWSER_NAMES[browser_name]])
except KeyError:
raise ValueError(browser_name + " is not a supported browser.")
return driver_path

Not able to find locator in appium python

I am new to appium python client and need your suggestions to solve my below issue.PFA uiautomator viewer screen shot.Not sure if this is the reason: after typing into email field, a keyboard opens up so password and sign in button are not located
I have downloaded a free sample xxx.apk and created below script to test it:
class CareZoneAndroidTests(unittest.TestCase):
"Class to run tests against the Care Zone app"
def setUp(self):
"Setup for the test"
desired_caps = {}
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '4.2'
desired_caps['deviceName'] = 'Android Emulator'
# Returns abs path relative to this file and not cwd
desired_caps['app'] = os.path.abspath(os.path.join(os.path.dirname(__file__),'D:/Programs/myapp/CareZone_v6.6.0.0 (flagship)_apkpure.com.apk'))
desired_caps['appPackage'] = 'com.carezone.caredroid.careapp.medications'
desired_caps['appActivity'] = 'com.carezone.caredroid.careapp.ui.activity.LandingActivity'
self.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
def tearDown(self):
"Tear down the test"
self.driver.quit()
def test_login(self):
"Test the Login Page launches correctly"
self.driver.implicitly_wait(120)
print "After WAIT----------------->>>>>>>"
#Click on Sign in button
element = self.driver.find_element_by_id("com.carezone.caredroid.careapp.medications:id/welcome_page_sign_toolbar_action")
self.driver.implicitly_wait(15)
element.click()
element = self.driver.find_element_by_id("com.carezone.caredroid.careapp.medications:id/welcome_page_sign_mail_edit")
self.driver.implicitly_wait(10)
element.click()
element.send_keys("abc#ini.com");
element = self.driver.find_element_by_id("com.carezone.caredroid.careapp.medications:id/welcome_page_sign_password_edit")
element.click()
element.send_keys("abc");
self.driver.implicitly_wait(10)
#element = self.driver.find_element_by_id("com.carezone.caredroid.careapp.medications:id/welcome_page_sign_bton")
#element = self.driver.find_element_by_accessibility_id('Sign In')
element = self.driver.find_element_by_android_uiautomator('new UiSelector().text("Sign In")')
element.click()
Issue:
test_login (main.CareZoneAndroidTests) Test the Login Page
launches correctly ... After WAIT----------------->>>>>>> ERROR
====================================================================== ERROR: test_login (main.CareZoneAndroidTests) Test the Login Page
launches correctly
---------------------------------------------------------------------- Traceback (most recent call last): File
"D:\Programs\myapp\CareZoneTests.py", line 42, in test_login
element = self.driver.find_element_by_android_uiautomator('new UiSelector().text("Sign In")') File
"D:\Programs\Python275\lib\site-packages\appium\webdriver\webdriver.py",
line 133, in find_element_by_android_uiautomator
return self.find_element(by=By.ANDROID_UIAUTOMATOR, value=uia_string) File
"D:\Programs\Python275\lib\site-packages\selenium\webdriver\remote\webdriver.py",
line 752, in find_element
'value': value})['value'] File "D:\Programs\Python275\lib\site-packages\selenium\webdriver\remote\webdriver.py",
line 236, in execute
self.error_handler.check_response(response) File "D:\Programs\Python275\lib\site-packages\appium\webdriver\errorhandler.py",
line 29, in check_response
raise wde NoSuchElementException: Message: An element could not be located on the page using the given search parameters.
Tried below but all are failing for the same reason:
element = self.driver.find_element_by_id("com.carezone.caredroid.careapp.medications:id/welcome_page_sign_bton")
element = self.driver.find_element_by_accessibility_id('Sign In')
element = self.driver.find_element_by_android_uiautomator('new
UiSelector().text("Sign In")')
Try to find element by ID :
element = self.driver.find_element_by_id('Sign In')
updated :
Try to put hidekeyboard(); before doing the action of selection an element in order to hide your keyboard !
Below code worked fine for me:
class CareZoneAndroidTests(unittest.TestCase):
"Class to run tests against the Care Zone app"
def setUp(self):
"Setup for the test"
desired_caps = {}
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '4.2'
desired_caps['deviceName'] = 'Android Emulator'
# Returns abs path relative to this file and not cwd
desired_caps['app'] = os.path.abspath(os.path.join(os.path.dirname(__file__),'D:/Programs/myapp/CareZone_v6.6.0.0 (flagship)_apkpure.com.apk'))
desired_caps['appPackage'] = 'com.carezone.caredroid.careapp.medications'
desired_caps['appActivity'] = 'com.carezone.caredroid.careapp.ui.activity.LandingActivity'
self.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
def tearDown(self):
"Tear down the test"
self.driver.quit()
def test_login(self):
"Test the Login Page launches correctly"
self.driver.implicitly_wait(120)
print "Sign in Page"
element = self.driver.find_element_by_xpath("//android.widget.TextView[#text='Have an account? Sign In']")
self.driver.implicitly_wait(15)
element.click()
element = self.driver.find_element_by_id("com.carezone.caredroid.careapp.medications:id/welcome_page_sign_mail_edit")
element.click()
element.send_keys("ja.i#c.com");
self.driver.implicitly_wait(3)
self.driver.keyevent(61)
element = self.driver.find_element_by_id("com.carezone.caredroid.careapp.medications:id/welcome_page_sign_password_edit")
element.click()
element.send_keys("ni");
self.driver.implicitly_wait(3)
print "Click TABS 2 times to get Sign In button-->>>>>>>"
self.driver.keyevent(61)
self.driver.keyevent(61)
element = self.driver.find_element_by_id("com.carezone.caredroid.careapp.medications:id/welcome_page_sign_bton")
element.click()
self.driver.implicitly_wait(120)
print "TEST OK"

Categories