我有一个非常简单的库,我希望将其作为依赖项包含在内。
我们必须手动将其作为脚本文件包含在内,因为它在全局范围内定义了很多变量(在全局范围内讨论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 NewTest(unittest.TestCase):
def setUp(self):
self.driver = webdriver.Firefox()
self.driver.implicitly_wait(30)
self.base_url = "https://developer.mozilla.org/"
self.verificationErrors = []
self.accept_next_alert = True
def test_new(self):
driver = self.driver
driver.get(self.base_url + "/en-US/docs/Web/HTML/Element/input/radio")
driver.find_element_by_id("contactChoice1").click()
driver.find_element_by_id("contactChoice2").click()
driver.find_element_by_id("contactChoice3").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
)。
该库由3个独立的文件组成,其中包括共享全局变量。
有太多的全局变量要使用Shimming或类似的东西..
我真的需要在全球范围内运行它们,并且:
var something = 'something else'
是否有效)最佳解决方案将包括'供应商'所有文件缩小的文件夹
有没有办法使用现有的插件/配置?