猿问

为什么出现错误 AttributeError: 'WebDriver'

获取行 self.driver.executes_script 错误

self.driver.executes_script("arguments[0].click();", new_notification) AttributeError: 'WebDriver' object has no attribute 'executes_script' None

但它们是一个类名


import unittest

from selenium import webdriver

from selenium.webdriver.common.keys import Keys

import HtmlTestRunner

import time



class Environment(unittest.TestCase):


    def setUp(self):


        self.driver = webdriver.Chrome(executable_path="F:\\automation\\chromedriver.exe")


    # login test case

    def test_first_page_login(self):

        driver = self.driver

        driver.maximize_window()

        driver.get("http://localhost/dashboard/user/login")

        self.driver.find_element_by_id('uemail').send_keys('xyz@abc.com')

        self.driver.find_element_by_id('upwd').send_keys('1234567890')

        self.driver.find_element_by_id('upwd').send_keys(Keys.RETURN)


    # login page going


    def test_going_notification_page(self):

        self.test_first_page_login()

        time.sleep(5)

        going_noti_page = self.driver.find_element_by_class_name('caret')

        print(self.driver.execute_script("arguments[0].click();", going_noti_page))

        new_notification = self.driver.find_element_by_class_name('fa-paper-plane')

        self.driver.executes_script("arguments[0].click();", new_notification)

        time.sleep(5)


    def tearDown(self):

        self.driver.quit()



if __name__ == "__main__":

        unittest.main(testRunner=HtmlTestRunner.HTMLTestRunner(output='F:\\automation\\reports'))


阿晨1998
浏览 2154回答 1
1回答
随时随地看视频慕课网APP

相关分类

Python
我要回答