问答详情
源自:7-3 webdriver常见元素定位(下)

display显示为none的元素,如何去操作呢?

#coding=UTF-8
from selenium import webdriver
import unittest

class weipinhui(unittest.TestCase):
    def setUp(self):
        self.driver=webdriver.Firefox()
        self.driver.maximize_window()
        self.driver.implicitly_wait(10)
        
        self.driver.get('https://www.vip.com/?wq=1')
        
    def test(self):
        driver=self.driver
        
        dis=driver.find_element_by_class_name('top-nav-list').is_displayed()
        print(dis)
        
        name=driver.find_element_by_css_selector('p.top-nav-list>span>a')
        
        
        name1=driver.find_element_by_xpath('/html/body/header/nav[1]/div/ul/li[4]/div/p/span[1]/a').click()
        
    def tearDown(self):
        self.driver.quit()
        
        
if __name__=='__main__':
    unittest.main()
        
   

提问者:慕先生4997562 2019-10-11 21:04

个回答

  • qq_fly_5
    2019-10-21 20:07:18

    用js脚本改变其属性状态