美文网首页
1 Call JavaScript

1 Call JavaScript

作者: 初见_0308 | 来源:发表于2019-06-27 16:51 被阅读0次

    '''

    set scroll par

    js='window.scrollTo(left margin,top margin)'

    execute_script(js)  :// execute the JavaScript program

    put content into textarea

    text='input text'

    js='var sum=document.getElementById(' textarea's id  ');sum.value='"+  text +"';'

    driver.execute_script(js)

    '''

    from selenium import webdriver

    from time import sleep

    driver=webdriver.Firefox()

    driver.get('http://www.baidu.com')

    driver.set_window_size(600,600)# appear scroll par of vertical and horizontal

    driver.find_element_by_id('kw').send_keys('JavaScript')

    driver.find_element_by_id('su').click()

    sleep(2)

    #set the scroll bar position by JS

    js='window.scrollTo(100,450);'

    driver.execute_script(js)

    sleep(3)

    driver.quit()

    相关文章

      网友评论

          本文标题:1 Call JavaScript

          本文链接:https://www.haomeiwen.com/subject/klkgoqtx.html