我有一个Flash编辑器应该在我的自动测试中打开和关闭,但当然有闪存问题。我尝试做什么:
def open_browser(self, profile):
global driver, testcase, Ui
# driver = webdriver.Firefox(profile)
driver = webdriver.Remote(
command_executor='http://127.0.0.1:4444/wd/hub',
desired_capabilities=DesiredCapabilities.FIREFOX)
driver.maximize_window()
driver.implicitly_wait(0.1)
return driver
from com.thoughtworks.selenium.FlashSelenium import FlashSelenium
import unittest
import time
from selenium import webdriver
class SmokeTests(unittest.TestCase):
@classmethod
def setUpClass(cls):
global driver, Ui, Base, UiNodes, MyFormsPage, actions, PmailPage, SharePage, FlashSelenium, flash
Base = BaseTest()
profile = webdriver.FirefoxProfile()
# profile.set_preference('plugin.state.flash', 0)
# profile.update_preferences()
driver = Base.open_browser(profile)
Ui = UiHelper(driver)
UiNodes = link.UINodes()
PmailPage = PmailPage(driver)
SharePage = SharePage(driver)
driver.get(config.Url.HOME)
flash = FlashSelenium(driver, "pdfForms")
def test_flash(self):
print "My flash test starts"
Ui.wait_for_element(link.W9FormNodes.FILL_ONLINE_BIG, "BIG FILL ONLINE BUTTON!").click()
time.sleep(10)
print "sleep is over"
print flash
flash.call("close")
所以我在这里开始测试selenium网格,打开我的链接,然后点击BIG按钮,我的flash编辑器就会打开。在那里,我向FlashSelenium提供了我的驱动程序和flash框架的ID。
<div id="flash-content" style="position:relative; z-index: 0;">
<object id="pdfForms" width="100%" height="100%" align="middle" bottommargin="0" rightmargin="0" leftmargin="0" topmargin="0" codebase="https://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000">
<param value="https://MY_TEST_ADDRESS.com/flash/wrapper2.swf?nocache=.20141202.102738" name="movie">
<param value="sameDomain" name="allowScriptAccess">
<param value="high" name="quality">
<param value="#ffffff" name="bgcolor">
<param value="type=editor&target_swf=https://MY_TEST_ADDRESS.com/flash/editor2.swf?ver=.20141208.074208&login_hash=T6k3fUBSgtqv1IDd4aBp&viewer_id=10970112&project_id=20077105&lang=en&path=https://MY_TEST_ADDRESS.com/flash/data&log_id=46042" name="FlashVars">
<embed width="100%" height="100%" align="middle" pluginspage="https://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" flashvars="type=editor&target_swf=https://MY_TEST_ADDRESS.com/flash/editor2.swf?ver=.20141208.074208&login_hash=T6k3fUBSgtqv1IDd4aBp&viewer_id=10970112&project_id=20077105&lang=en&path=https://MY_TEST_ADDRESS.com/flash/data&log_id=46042" allowscriptaccess="sameDomain" name="pdfForms" bottommargin="0" rightmargin="0" leftmargin="0" topmargin="0" bgcolor="#ffffff" quality="high" src="https://MY_TEST_ADDRESS.com/flash/wrapper2.swf?nocache=.20141202.102738">
这是我得到的:
Error
Traceback (most recent call last):
File "/Users/mkurganskiy/Documents/Python/PDFfiller_Tests/tests/teeeeest.py", line 55, in test_flash
flash.call("close")
File "/Users/mkurganskiy/Documents/Python/PDFfiller_Tests/com/thoughtworks/selenium/FlashSelenium.py", line 43, in call
self.flashJSStringPrefix = self.checkBrowserAndReturnJSPrefix()
File "/Users/mkurganskiy/Documents/Python/PDFfiller_Tests/com/thoughtworks/selenium/FlashSelenium.py", line 133, in checkBrowserAndReturnJSPrefix
appName = self.seleniumObj.get_eval("navigator.userAgent")
AttributeError: 'WebDriver' object has no attribute 'get_eval'