zoukankan      html  css  js  c++  java
  • selenium自动化关于虚拟DOM 元素点击

    例子:国际化语言切换
    xp = '//*[@id="app"]/div/div[1]/div/div/div[1]/div[2]/div/div/div[2]/span' #先点击下拉按钮语言框
    element2 = self.driver.find_element_by_xpath(xp) #定位语言框的元素
    lun = self.driver.find_element_by_xpath("//*[text()='繁體中文']/ancestor-or-self::li") #定位选择的元素
    ActionChains(self.driver).move_to_element(element2).perform() #模拟鼠标悬停
    # ActionChains(self.driver).click(lun).perform() # 按住

    self.driver.execute_script("arguments[0].click();", lun) #点击选择悬停获得的元素

    如果有滑条轮:
    self.driver.execute_script("arguments[0].scrollIntoView();", lun)  #使滚动条下滑至要定位的元素位置
    sleep(3)   #等待几秒查看滚动条是否下滑
    lun.click()     #点击操作
     
  • 相关阅读:
    [solr]
    [solr]
    [Linux] CentOS 加入开机启动
    [Linux] VirtualBox
    [Eclipse]
    [JBoss]
    [solr]
    [solr]
    [solr]
    [solr]
  • 原文地址:https://www.cnblogs.com/peanut-HS/p/13213490.html
Copyright © 2011-2022 走看看