我是靠谱客的博主 纯真朋友,这篇文章主要介绍selenium常用js脚本,现在分享给大家,希望可以做个参考。

# 禁用按钮的只读属性(已验证正常),入参msg为需要去除只读属性的元素driver定位 例:msg = driver.find_element(By.Id, 'name')
    def execute_script(self, msg):
        return self.driver.execute_script("arguments[0].removeAttribute('readonly')", msg)

    # 滑动页面滚动条,参数target为页面遮挡的元素定位
    def slide_bar(self, target):
        self.driver.execute_script("arguments[0].scrollIntoView();", target)

    # 普通定位无法点击时,可以尝试此方法
    def js_find_element(self,):
        button = self.driver.find_element("//*[@id='report_attendance_org']/form[1]/div[2]/div[1]/div/div[2]/input")
        self.driver.execute_script("$(arguments[0]).click()", button)

最后

以上就是纯真朋友最近收集整理的关于selenium常用js脚本的全部内容,更多相关selenium常用js脚本内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(110)

评论列表共有 0 条评论

立即
投稿
返回
顶部