Ifram and select Chrome 67 version of 2.46 5453

Import the webdriver Selenium from 
#shu meter operation
from selenium.webdriver.common.action_chains Import ActionChains
from the Select selenium.webdriver.support.select Import

Driver = webdriver.Firefox ()
driver.get ( 'http://ui.imdsx.cn/ HTML / ')
Import Time
the time.sleep (. 1)
driver.execute_script (' the window.scrollTo (0,1500); ')
the time.sleep (. 1)
# Screenshot
# driver.get_screenshot_as_file (' pngdemo.png ')
#
# EL driver.find_element_by_css_selector = ( '[the href = "/ new new-index /"]')
# el.click ()
# Print (driver.window_handles)
# obtain all tag name tag
# Handles = driver.window_handles
# switches to the new tab page, outdated written
# driver.switch_to_window (Handles [. 1])
# Time.sleep(1)
#
# Driver.switch_to.window (Handles [. 1])
#
#
# driver.find_element_by_css_selector ( '# NewTag'). Send_keys ( 'XXXX')
#
# Close Close Close ruguo current page, the page must manually switch, not automatically switching
# driver.close ()
# driver.switch_to.window (Handles [0])
# driver.find_element_by_css_selector ( '# I1'). send_keys ( 'XXXX')
# exit drive, the operating point x
# driver.quit ()
# handover ifram
# What is ifram \\
# id attributes or if the attribute name may be directly filled in the frame
# id attribute, and if there is no name acceptable elementobj
# eleobj driver.find_element_by_css_selector = ( '[the src = "/ New- index / "] ')
# driver.switch_to.frame (' Top-Frame ')
# driver.switch_to.frame (eleobj)
# driver.find_element_by_css_selector (' # NewTag ').send_keys('xxxx')
# driver.switch_to.frame('baidu-frame')
# driver.find_element_by_css_selector('#kw').send_keys('xxxx')
# #返回上一层,qingkong
# # driver.switch_to.parent_frame()
# #浏览器句柄
# print(driver.window_handles)
#
# handles = driver.window_handles
# 下面这两个是一样的
# driver.switch_to_window(handles[1])
# driver.switch_to.window(handles[1])
#
#
# driver.find_element_by_css_selector('#newtag').clear()
# driver.switch_to.frame('baidu-frame')
#
# driver.find_element_by_css_selector('#kw').clear()
#
#
#
# driver.find_element_by_css_selector('#i1') Close, if the pointer is switched, you must manually switch back, cut back will not default# #Guanb
#

#
# Driver.switch_to.frame ( 'Top-FRAM')
# driver.find_element_by_css_selector ( '# alert'). The Click ()
# #alert alert processing is confirmed,
# #Print (driver.swith_to.alert.text)
# Driver .switch_to.alert.accept () # confirm
# driver.switch_to.dismiss () # cancel

#webdriver the api is above the finished


#element of api
# driver.find_element_by_css_selector EL = ( 'DIS1 #')
# determines whether the element in display page
#Print (el.is_displayed ())

# driver.execute_script ( "document.getElementById ( 'DIS1'). style.display = '';.")
# Print (el.is_displayed ())
#
# driver.find_element_by_css_selector ( '# DIS1'). the Click ()


# suspension element to take
# driver.find_element_by_css_selector EL = ( 'a #')
# = Driver DIS1.find_element_by_css_selector('#dis1')
Mouse ##, self this class. Chain program, when called to perform being executed
# ActionChains (Driver) .move_to_element (EL) .click (DIS1) .perform ()

# drag and drop images
# Source = driver.find_element_by_css_selector ( '# dragger')
# = source1 Driver. find_element_by_css_selector ( 'dragger1 #')
# = driver.find_element_by_css_selector target ( '# I1')
# = driver.find_element_by_css_selector Target1 ( '# I2')
# ActionChains (Driver) .drag_and_drop (Source, target) .drag_and_drop (Source1, Target1) .perform ()

#select amount of expertise to provide the label selenium select

# instantiated receiving a select tag select
#dingwreiselect
# analysis: attributes are name, it is positioned by XPath
select driver.find_element_by_xpath = ( "// select [. 1]" )
# positioned by the option select tag value field
Select (select) .select_by_value ( '4 '




================================================== ===============================
three kinds waiting

# Big project waiting
# The first is time.sleep () This is the low of
the time # hermit wait driver.implicitly_wait (10) dangni open the URL, the first time to wait, and so after you successfully loaded
# general application globally, basic do

# wait last display library to be imported
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions AS EC
from selenium.webdriver.common.by import By
#until every 0.5 seconds scan the positioned elements, found a return, you can not find the error
WebDriverWait (Driver, 10, 0.5) .until (EC.visibility_of_element_located ((By.ID, 'su')))

* by means, for example:
the demolition of Ganso demo parameters to be divided, passing into, printed
def demo(name,age):
print(name)
print(age)
v = ('dsx',18)
demo(*v)

dsx
18

Caton problem #guibi environment, it can also perform a normal 
# ELE = WebDriverWait (Driver, 10,1) .until (EC.presence_of_element_located ((By.ID, 'I1')))
# ele.send_keys ( 'xxxx')
= WebDriverWait ELE (Driver, 10,1) .until (EC.presence_of_element_located ((By.ID, 'I12')))
# ele.send_keys ( 'xxxx')

# how to avoid abnormal error
# way by showing us waiting, this dynamic identification element, every time the number of seconds sweep seedlings, step and can configure their own timeout,


## which may be enclosed work
# CSS = 'CSS => I1 #'
# WAIT_ELEMENT
# get_element (CSS)



Guess you like

Origin www.cnblogs.com/yqcf/p/9501060.html
67