The Artima Developer Community
Sponsored Link

Python Answers Forum
Need Help Please

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
dilshad randhawa

Posts: 2
Nickname: dilshad
Registered: Jan, 2017

Need Help Please Posted: Jan 4, 2017 4:38 PM
Reply to this message Reply
Advertisement
Hi All,
I want to see how it is like to modify existing code. Please see below if someone can help me I will appreciate it:

If I want to modify a existing python code to do the following:


1. Opens up to Run in Internet Explorer and Chrome

2. Turn this code to be run as loop

3. Time thread where it goes in slow or fast motion

4. Close browser

5. Then re-run this in PyCharm compiler....



# -*- coding: utf-8 -*-
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import NoSuchElementException
from selenium.common.exceptions import NoAlertPresentException
import unittest, time, re

class GmailLogin(unittest.TestCase):
def setUp(self):
self.driver = webdriver.Firefox()
self.driver.implicitly_wait(30)
self.base_url = "https://accounts.google.com/"
self.verificationErrors = []
self.accept_next_alert = True

def test_gmail_login(self):
driver = self.driver
driver.get(self.base_url + "/ServiceLogin?service=mail&passive=true&rm=false&continue=https:// mail.google.com/mail/&ss=1&scc=1&ltmpl=default&ltmplcache=2& emr=1&osid=1#identifier")
driver.find_element_by_id("Email").clear()
driver.find_element_by_id("Email").send_keys("DilshadRandhawa@gmail.com")
driver.find_element_by_id("next").click()
driver.find_element_by_id("Passwd").clear()
driver.find_element_by_id("Passwd").send_keys("Vatika12")
driver.find_element_by_id("signIn").click()
driver.find_element_by_css_selector("span.gb_8a.gbii").click()
driver.find_element_by_id("gb_71").click()

def is_element_present(self, how, what):
try: self.driver.find_element(by=how, value=what)
except NoSuchElementException as e: return False
return True

def is_alert_present(self):
try: self.driver.switch_to_alert()
except NoAlertPresentException as e: return False
return True

def close_alert_and_get_its_text(self):
try:
alert = self.driver.switch_to_alert()
alert_text = alert.text
if self.accept_next_alert:
alert.accept()
else:
alert.dismiss()
return alert_text
finally: self.accept_next_alert = True

def tearDown(self):
self.driver.quit()
self.assertEqual([], self.verificationErrors)

if __name__ == "__main__":
unittest.main()

Topic: writing a number variable to a file Previous Topic   Next Topic Topic: Need Help Please

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use