首页
学习
活动
专区
圈层
工具
发布
    • 综合排序
    • 最热优先
    • 最新优先
    时间不限
  • 来自专栏码匠的流水账

    解决WebDriverWait中的cannot be applied的问题

    序 本文主要描述下如何解决WebDriverWait中的cannot applied的问题。 问题 webDriverWait.until(ExpectedConditions.presenceOfElementLocated(By.className("ready"))); 升级了pom依赖, doc FluentWait changes WebDriverWait().until(ExpectedCondition…) fails with java.lang.NoSuchMethodError

    79410发布于 2018-09-17
  • 来自专栏从零开始学自动化测试

    Selenium2+python自动化38-显示等待(WebDriverWait

    一、参数解释 1.这里主要有三个参数: class WebDriverWait(object):driver, timeout, poll_frequency 2.driver:返回浏览器的一个实例,这个不用多说 Example: from selenium.webdriver.support.ui import WebDriverWait \n element = WebDriverWait(driver, 10).until(lambda x: x.find_element_by_id("someId")) \n is_disappeared = WebDriverWait(driver, 30, 1, (ElementNotVisibleException)).\ \n until_not( driver = webdriver.Firefox() driver.get("http://www.baidu.com") # 等待时长10秒,默认0.5秒询问一次 WebDriverWait(

    1.5K60发布于 2018-04-08
  • 来自专栏python3

    python里三种等待元素的方法

    看看第三种方法,比较灵活 三、 显性等待 WebDriverWait,配合该类的until()和until_not()方法,表示程序每隔x秒去判断一下指 定的元素是否加载完,加载完了就执行下一步,否则继续每隔 (u"百度一下,你就知道")) '''判断title,返回布尔值''' WebDriverWait(driver,10).until(EC.title_contains(u"百度一下")) '''判断 dom树里,并不代表该元素一定可见,如果定位到就 返回WebElement''' WebDriverWait(driver,10).until(EC.visibility_of_element_located (driver.find_element(by=By.ID,value='kw'))) '''判断元素是否可见,如果可见就返回这个元素''' WebDriverWait(driver,10).until //*[@id='gxszButton']/a[1]").click() instance = WebDriverWait(driver,10).until(EC.alert_is_present()

    2.2K10发布于 2020-01-09
  • 来自专栏全栈测试

    Selenium自动化测试-设置元素等待

    selenium中有三种时间等待: 强制等待:sleep 隐式等待:implicitly_wait 显示等待:WebDriverWait 1.sleep 让程序暂停运行一定时间,等待时间到达后继续运行 WebDriverWait 等待某个条件成立时继续执行,否则在达到最大时长时抛出超时异常TimeoutException。 WebDriverWait一般和until()和until_not()配合使用: until() 当某元素出现或什么条件成立则继续执行 until_not 当某元素消失或什么条件不成立则继续执 WebDriverWait 使用WebDriverWait,需要先导入WebDriverWait模块。 from selenium.webdriver.support.ui import WebDriverWait 我们使用WebDriverWait方式来定位百度页面的新闻链接, 代码如下: from selenium

    2.2K10发布于 2019-11-14
  • 来自专栏muller的测试分享

    app自动化测试(Android)--显式等待机制

    WebDriverWait类解析WebDriverWait 用法代码Python 版本WebDriverWait( driver,timeout,poll_frequency=0.5,ignored_exceptions 单位秒poll_frequency: 检测的间隔步长,默认为 0.5signored_exceptions: 执行过程中忽略的异常对象,默认只忽略 TimeoutException 异常类Java 版本WebDriverWait ().until( expected_conditions.presence_of_element_located(locator))Java 版本new WebDriverWait( )\ ().until( expected_conditions.visibility_of_element_located(locator))Java 版本new WebDriverWait( ).until wait=new WebDriverWait(driver, 10); wait.until(ExpectedConditions.elementToBeClickable(locator));

    95130编辑于 2023-01-03
  • 来自专栏测试开发社区

    selenium&appium中的三种等待方式---基于python

    appium时,等待下个等待定位的元素出现,特别是web端加载的过程,都需要用到等待,而等待方式的设置是保证脚本稳定有效运行的一个非常重要的手段,在selenium中(appium通用)常用的等待分为显示等待WebDriverWait 包 from selenium.webdriver.support.ui import WebDriverWait #导入 time 包 from sleep import sleep driver = webdriver.Firefox() driver.get("http://www.baidu.com") #WebDriverWait()方法使用 element=WebDriverWait( driver.quit() 关于强制等待和隐式等待在上面注释中已做了说明 下面主要介绍一下WebDriverWait() 显示等待,语法格式如下: WebDriverWait(self,driver, timeout,poll_frequency=POLL_FREQUENCY,ignored_exceptions=None).until(self,method,message=) 或者 WebDriverWait

    2K20发布于 2019-09-20
  • 来自专栏Hank’s Blog

    15.selenium_case04

    webdriver from selenium.webdriver.common.keys import Keys from selenium.webdriver.support.wait import WebDriverWait paste.html') driver.execute_script("contentIn('"+ content +"');") timeout = 5 content_copy = WebDriverWait window.scrollTo(0, document.body.scrollHeight)") time.sleep(1) # 添加扩展链接 expand_check = WebDriverWait ]', )) expand_link_box.send_keys(expand_link) time.sleep(1) # 自动封面 front_img = WebDriverWait "]/label[3]/div/input', )) front_img.click() time.sleep(1) # 保存草稿 save_draft = WebDriverWait

    44220发布于 2020-09-17
  • 来自专栏QA一隅

    Appium 元素等待设置

    方法WebDriverWait格式参数如下: from selenium.webdriver.support.ui import WebDriverWait WebDriverWait(driver, WebDriverWait()一般和until()或until_not()方法配合使用,另外,lambda提供了一个运行时动态创建函数的方法。 from selenium.webdriver.support.ui import WebDriverWait WebDriverWait(driver,10).until(lambda x:x.find_element_by_id element_wait.py from find_element.kyb_login import driver from selenium.webdriver.support.ui import WebDriverWait WebDriverWait(driver,3).until(lambda x:x.find_element_by_id('com.tal.kaoyan:id/mainactivity_button_forum

    1.6K20发布于 2021-08-09
  • 来自专栏测试人

    web自动化测试-文件上传与弹框处理

    http://sahitest.com/demo/alertTest.htm") driver.find_element_by_name("b1").click() # 添加显示等待,等待弹框的出现 WebDriverWait wait = new WebDriverWait(driver, 5); wait.until(ExpectedConditions.alertIsPresent()); // 切换到弹框 http://sahitest.com/demo/promptTest.htm") driver.find_element_by_name("b1").click() #添加显示等待,等待弹框的出现 WebDriverWait wait = new WebDriverWait(driver, 10); wait.until(ExpectedConditions.alertIsPresent()); // 切换到弹框 wait = new WebDriverWait(driver, 5); wait.until(ExpectedConditions.alertIsPresent()); // 切换到弹框

    1.3K30编辑于 2022-05-17
  • 来自专栏python3

    Python——按键操作、时间等待、点击

    引入一个网页等待的包from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support.ui 网页等待 值1:等待的对象 值2:等待的时间 # WebDriverWait 经常和until not 一起使用 until直到 # lambda 匿名函数 is_displayed是否已经显示 is_visible = WebDriverWait(driver,10).until(lambda driver : button.is_displayed()) print(is_visible) button.click()      WebDriverWait()和time.sleep()的区别:(1)都是让程序等待指定执行的时间(2)time的时间是固定的,时间长短不会随着标签的加载速度而改变 ;WebDriverWait时间是固定的,等待多少时间要看标签的加载时间和指定的固定时间(3)如果在指定时间内,标签仍然没有加载出来,那么time和WebDriverWait都会报出异常。

    2.1K10发布于 2020-01-06
  • 来自专栏赖权华的笔记

    Python+Selenium笔记(十):元素等待机制

    #设置超时时间为10秒 driver.implicitly_wait(10) (三) 显式等待 WebDriver提供了WebDriverWait类和expected_conditions模块来实现显式等待 (四) WebDriverWaitWebDriverWait(driver, timeout, poll_frequency=POLL_FREQUENCY, ignored_exceptions=None 预期等待条件(前置条件) 简单说明 element_to_be_clickable(locator) 参数:locator,指一组(By,locator) 例如:WebDriverWait(driver 下面这个是WebDriverWait类自带的部分注释。 \n element = WebDriverWait(driver, 10).until(lambda x: x.find_element_by_id("someId")) \

    3.5K50发布于 2018-04-27
  • 来自专栏测吧测试开发

    技术分享 | Web自动化之显式等待与隐式等待

    版本 import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait ; ... // 设置10秒的最大等待时间,等待 (By.TAG\_NAME, "title") 这个元素点击 WebDriverWait wait = new WebDriverWait(driver webdriver.Chrome() driver.get('https://ceshiren.com') # 显示等待10秒,直到 wait\_ele\_for 返回 true WebDriverWait category\_name = (By.LINK\_TEXT, "开源项目") # 加入显式等待 WebDriverWait(self.driver, 10).until( wait = new WebDriverWait(driver, 10); wait.until(ExpectedConditions.elementToBeClickable(locator

    1.3K30编辑于 2022-04-27
  • 来自专栏软件测试开发技术

    ​技术分享 | Web自动化之显式等待与隐式等待

    import expected_conditions ... # 设置10秒的最大等待时间,等待 (By.TAG_NAME, "title") 这个元素点击 WebDriverWait(driver, 版本 import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait ; ... // 设置10秒的最大等待时间,等待 (By.TAG_NAME, "title") 这个元素点击 WebDriverWait wait = new WebDriverWait(driver category_name = (By.LINK_TEXT, "开源项目") # 加入显式等待 WebDriverWait(self.driver, 10).until( wait = new WebDriverWait(driver, 10); wait.until(ExpectedConditions.elementToBeClickable(locator

    1.3K30编辑于 2022-04-27
  • 抖音自动发布软件,批量上传视频发布工具,易语言框架分享【源码】

    ) login_btn.click() time.sleep(2) # 切换到账号密码登录 switch_btn = WebDriverWait 1]/input')) ) username_input.send_keys(self.username) password_input = WebDriverWait password_input.send_keys(self.password) time.sleep(1) # 点击登录 submit_btn = WebDriverWait print(f"开始上传视频: {video_path}") # 等待上传完成 time.sleep(10) try: WebDriverWait 视频上传超时") return False # 输入描述 if description: desc_input = WebDriverWait

    36510编辑于 2025-07-13
  • 来自专栏python-爬虫

    深入selenium三种等待方式使用

    #隐式等待,失败概率高,可不用 browser.implicitly_wait(10) #在10秒内,如果网页全部加载完成(包含js),则执行下一步,否则一直等到10秒结束后,在执行下一步 方法三 WebDriverWait (显示等待)(推荐使用) from selenium.webdriver.support.wait import WebDriverWait 参数 driver: 传入WebDriver实例,即我们上例中的 (u"百度一下")) '''判断title,返回布尔值''' WebDriverWait(driver,10).until(EC.presence_of_element_located((By.ID (driver.find_element(by=By.ID,value='kw'))) '''判断元素是否可见,如果可见就返回这个元素''' WebDriverWait(driver,10).until //*[@id='gxszButton']/a[1]").click() instance = WebDriverWait(driver,10).until(EC.alert_is_present(

    5.6K32发布于 2019-09-11
  • 来自专栏测吧测试开发

    技术分享 | web自动化测试-文件上传与弹框处理

    http://sahitest.com/demo/alertTest.htm") driver.find_element_by_name("b1").click() # 添加显示等待,等待弹框的出现 WebDriverWait wait = new WebDriverWait(driver, 5); wait.until(ExpectedConditions.alertIsPresent()); // 切换到弹框 /demo/promptTest.htm"); driver.findElement(By.name("b1")).click(); // 添加显示等待,等待弹框的出现 WebDriverWait wait = new WebDriverWait(driver, 10); wait.until(ExpectedConditions.alertIsPresent()); // wait = new WebDriverWait(driver, 5); wait.until(ExpectedConditions.alertIsPresent()); // 切换到弹框

    2K20编辑于 2022-05-17
  • 小红书自动发布工具,抖音快手自动发布作品,上传视频python开源

    login_xiaohongshu(self): self.driver.get('https://www.xiaohongshu.com/') try: WebDriverWait EC.presence_of_element_located((By.CLASS_NAME, 'login-btn')) ).click() WebDriverWait publish') time.sleep(3) if video_path: upload_btn = WebDriverWait WebDriverWait(self.driver, 120).until( EC.url_contains('creator.douyin.com') WebDriverWait(self.driver, 120).until( EC.url_contains('cp.kuaishou.com') )

    56510编辑于 2025-07-15
  • 来自专栏python-爬虫

    python获取淘宝登入cookies

    as EC import time, random from selenium import webdriver from selenium.webdriver.support.wait import WebDriverWait chromeOptions,executable_path=executable_path) time.sleep(random.uniform(1, 3)) driver.get(url) wait = WebDriverWait (driver,10) WebDriverWait(driver,60,1).until(EC.presence_of_element_located((By.XPATH,'//*[@class="forget-pwd J_Quick2Static"]'))) driver.find_element_by_xpath('//*[@class="forget-pwd J_Quick2Static"]').click() WebDriverWait class="weibo-login"]'))) driver.find_element_by_xpath('//a[@class="weibo-login"]').click() #新浪登入 WebDriverWait

    2.9K20发布于 2020-06-19
  • 来自专栏软件测试开发技术

    技术分享 | web自动化测试-文件上传与弹框处理

    http://sahitest.com/demo/alertTest.htm") driver.find_element_by_name("b1").click() # 添加显示等待,等待弹框的出现 WebDriverWait wait = new WebDriverWait(driver, 5); wait.until(ExpectedConditions.alertIsPresent()); // 切换到弹框 http://sahitest.com/demo/promptTest.htm") driver.find_element_by_name("b1").click() #添加显示等待,等待弹框的出现 WebDriverWait wait = new WebDriverWait(driver, 10); wait.until(ExpectedConditions.alertIsPresent()); // 切换到弹框 wait = new WebDriverWait(driver, 5); wait.until(ExpectedConditions.alertIsPresent()); // 切换到弹框

    1.2K30编辑于 2022-05-17
  • 来自专栏站长的编程笔记

    【说站】python Selenium如何等待元素出现

    诱导WebDriverWait设置expected_conditions作为presence_of_element_located()检查元素是否存在于页面的 DOM 上的期望。 所以有效的代码行将是: WebDriverWait(browser, 20).until(EC.presence_of_element_located((By.CSS_SELECTOR, ".reply-button 需要诱导WebDriverWait设置。 所以在你的用例中,代码行将是: email = WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.CSS_SELECTOR 要诱导WebDriverWait设置expected_conditions作为element_to_be_clickable()检查元素是否可见并启用以便您可以单击它的期望。

    1.8K40编辑于 2022-11-24
领券