对flash elemen执行flash方法

2024-06-08 08:22:00 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个flash编辑器,应该在我的autotests中打开和关闭,但是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网格上开始测试,打开我的链接,然后点击大按钮,我的flash编辑器就会打开。我给了FlashSelenium我的驱动程序和flash帧的id。在

^{pr2}$

我得到的是:

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'

Tags: importselfcomuibasedefdriverselenium