会话ID下的Firefox中的硒测试

时间:2018-06-27 13:29:39

标签: python-3.x selenium firefox selenium-webdriver

E
======================================================================
ERROR: test_LoginCorrect (__main__.LoginCorrect)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "demo.py", line 12, in test_LoginCorrect
    driver= webdriver.Remote(desired_capabilities=DesiredCapabilities().FIREFOX,command_executor='http://0.0.0.0:4444')
  File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 156, in __init__
    self.start_session(capabilities, browser_profile)
  File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 248, in 

     start_session
     self.session_id = response['sessionId']

TypeError: string indices must be integers

----------------------------------------------------------------------
Ran 1 test in 20.878s
//Formatting is not properly done

    FAILED (errors=1)

我的测试用例文件:

import unittest
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

class LoginCorrect(unittest.TestCase):
def setUp(self):
    self.driver = webdriver.Remote(command_executor='http://0.0.0.0:4444/wd/hub', desired_capabilities=DesiredCapabilities.FIREFOX) 

def test_LoginCorrect(self):
    user ="shubh"
    pwd= "sha123#56su"
    driver= webdriver.Remote(desired_capabilities=DesiredCapabilities().FIREFOX,command_executor='http://0.0.0.0:4444')
    driver.get("http://0.0.0.0:8000/login")
    elem = driver.find_element_by_id("id_username")
    elem.send_keys(user)
    elem = driver.find_element_by_id("id_password")     
    elem.send_keys(pwd)
    driver.find_element_by_class_name('btn-block').click()

def tearDown(self):
    self.driver.quit()

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

我的机器具有Linux 16.04LTS和硒3.3.0 有人可以解决这个问题吗?

0 个答案:

没有答案