Loading [MathJax]/jax/output/CommonHTML/config.js
首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >selenium (phpunit)单击下拉链接

selenium (phpunit)单击下拉链接
EN

Stack Overflow用户
提问于 2014-03-17 02:18:54
回答 2查看 1.4K关注 0票数 0

我想要能够点击链接从下拉使用硒与phpunit。我不知道如何使它发生,谁能给我示范或相关的教程,张贴或任何东西,可以帮助我弄清楚。

当我尝试单击元素而没有将鼠标放在下拉菜单上时,我得到了以下错误:

元素当前不可见,因此可能无法与命令.交互。

谢谢。

编辑:当我说“下拉”时,我不是指常规选择。它更像弹出窗口,您可以看到下面的示例:http://investing.com

看看他们如何构建菜单,我想要点击‘技术’->‘’,例如。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2014-03-19 00:00:22

查看这篇文章:Selenium:如何从选择菜单中选择一个选项?

您可以找到更多关于这个这里的信息。

代码语言:javascript
运行
AI代码解释
复制
select(selectLocator, optionLocator)

Arguments:

    selectLocator - an element locator identifying a drop-down menu
    optionLocator - an option locator (a label by default)

Select an option from a drop-down using an option locator.

Option locators provide different ways of specifying options of an HTML Select element (e.g. for selecting a specific option, or for asserting that the selected option satisfies a specification). There are several forms of Select Option Locator.

    label=labelPattern: matches options based on their labels, i.e. the visible text. (This is the default.)
        label=regexp:^[Oo]ther
    value=valuePattern: matches options based on their values.
        value=other
    id=id: matches options based on their ids.
        id=option1
    index=index: matches an option based on its index (offset from zero).
        index=2

If no option locator prefix is provided, the default behaviour is to match on label.

给戴夫亨特的学分

我用的是:

代码语言:javascript
运行
AI代码解释
复制
$search13 = $this->webDriver->findElement(WebDriverBy::id('id_of_dropdown_field'));
$search13->click(); // Clicking on the dropdownfield

$this->webDriver->getKeyboard()->pressKey('ARROW_DOWN'); // Will go down in your dropdown selection )

sleep(1);

$this->webDriver->getKeyboard()->pressKey('ENTER'); // Enter for submitting your selection

编辑:http://www.anitpatel.net/2012/02/25/selenium-webdriver-how-to-click-on-a-hidden-link-or-menu/,这个是用java解释的,但他所做的基本上是鼠标在/悬停和等待。然后他点击元素。我不是一个java天才,但这是一个如何使用它的例子。

您可以使用:

代码语言:javascript
运行
AI代码解释
复制
string mouseOver(string $locator)

这将模拟用户在指定元素上悬停鼠标。指南/3.1/en/selenium.html

票数 0
EN

Stack Overflow用户

发布于 2014-09-23 01:36:14

使用必需选项值的xpath检查元素是否可见。

$this->isElementPresent($xpath); $this->click($xpath);

如果为真,则单击()方法选择指定的选项。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22451708

复制
相关文章
Selenium中单击Element:ElementClickInterceptedException
element = driver.find_element_by_css(‘div[class*=”loadingWhiteBox”]’)
kirin
2021/04/02
1.1K0
Selenium处理下拉列表
在执行Selenium自动浏览器测试时,很多时候需要处理下拉菜单。下拉菜单通常用于表单中,在节省空间和防止用户在表单中选择错误的选项时非常有用。因此在测试任何网站或访问表单时,如何使用Selenium处理下拉列表显得尤为重要。
FunTester
2020/07/22
6.2K0
selenium下拉框选择
下拉框结构如下,我需要选择的是new: html为: <select id="condition_type" name="condition_type" class="notification-req
机器学习和大数据挖掘
2019/07/02
3.3K0
Selenium 操作下拉框
使用 Selenium 进行 Web 端的自动化测试的时候,不能通过 findElement 进行自动选择,后来发现,需要先声明一个 Select 类型,再进行选择,实现方法如下:
zucchiniy
2019/10/30
3.7K0
python selenium 下拉框 selector
from selenium import webdriver from selenium.webdriver.support.select import Select from time import sleep
用户5760343
2019/07/05
2K0
selenium下拉到页面最底端
selenium操控浏览器下拉到页面最底端: #!/usr/bin/env python # -*- coding: utf-8 -*- from selenium import webdriver import time if __name__ == '__main__': url = "http://blog.csdn.net/" browser = webdriver.Chrome() browser.get(url) browser.execute_scrip
机器学习和大数据挖掘
2019/07/02
1.9K0
Python Selenium下拉列表元素定位
1.定位父元素select,然后通过tag name找到所有option,得到option元素的数组,然后通过数组索引定位,最后click.
十四君
2019/11/23
2K0
PHPUnit Mock 测试
本文介绍了 PHPUnit Mock 测试。 假设 foo 函数调用了 bar 函数,那么在对 foo 函数进行单元测试会有两个问题: foo 函数依赖于 bar 函数的结果,那么在对 foo 进行单元测试的时候必然会引入 bar ,那么这样子单元测试就没意义了,如果测试不通过,那么无法保证 bug 出在 foo 还是 bar。 bar 函数可能在测试环境不可执行,那么 foo 无法获取 bar 的执行结果,从而无法对 foo 进行单元测试。 Mock 测试就是为了解决上面的问题而出现的,使用 Mock 我
康怀帅
2018/02/28
1.1K0
PHPUnit 手册【笔记】
一、安装 composer require --dev phpunit/phpunit ^6.5 composer require --dev phpunit/dbunit 二、编写测试 A.PHPUnit编写测试 1.基本惯例与步骤:
硬核项目经理
2019/08/06
1.8K0
Selenium Webdriver之点击图像链接
图像链接是Web页面中由图像表示的链接,当点击该图片(链接)时,将导航到另一个窗口或页面。
软测小生
2019/09/10
2.4K0
Selenium Webdriver之点击图像链接
爬虫selenium中动作链接ActionChains
一.基本语法 生成一个动作actions=ActionChains(driver) 动作添加方法actions.方法 执行 actions.perform() 二.方法列表 click(on_element=None) ——单击鼠标左键 click_and_hold(on_element=None) ——点击鼠标左键,不松开 context_click(on_element=None) ——点击鼠标右键 double_click(on_element=None) ——双击鼠标左键 drag_and_drop
小小咸鱼YwY
2020/06/19
8200
PHPUnit 详解
本文介绍了 PHP 单元测试框架 PHPUnit。 官方网站:https://phpunit.de/ GitHub:https://github.com/sebastianbergmann/phpunit 安装 composer 引入,执行命令或直接编辑文件。 $ composer require --dev phpunit/phpunit { "require-dev": { "phpunit/phpunit": "^6.2" } } 使用 use PHPUnit\Framework\
康怀帅
2018/02/28
8080
使用 Python Selenium 提取动态生成下拉选项
在进行网络数据采集和数据分析时,处理动态生成的下拉菜单是一个常见的挑战。Selenium是一个强大的Python库,可以让你自动化浏览器操作,比如从动态生成的下拉菜单中选择选项。这是一个常见的网页爬虫和数据收集者面临的挑战,但是Selenium让它变得简单。
jackcode
2023/06/07
1.3K0
使用 Python Selenium 提取动态生成下拉选项
Selenium处理多选项下拉框列表
你穿过世事朝我走来 迈出的每一步都留下了一座空城 这时,一支从来世射出的毒箭命定了我 唯一的退路 --仓央嘉措
Altumn
2019/10/20
4.2K0
Selenium处理单选项下拉框列表
UI自动化测试中,经常会遇到下拉框列表选项,常见的下拉框列表有:单选项下拉框,多选项下拉框。
Altumn
2019/10/21
4.3K0
在 Python 中使用 Selenium 打开链接
使用 Selenium 打开链接的最简单方法是使用 WebDriver 对象的 get() 方法。此方法指示浏览器导航到指定的 URL。
很酷的站长
2023/08/11
8590
在 Python 中使用 Selenium 打开链接
Selenium - 获取页面跳转之后的链接
今天在使用Flask+Selenium开发的时候遇到了一个天坑,这个页面会自动跳转到新页面,但是我使用driver.current_url无法获取到最新的页面url,获取到的还是driver.get(url)的
用砖头敲代码
2022/11/22
3.2K0
Python+Selenium笔记(八):操作下拉菜单
(一) Select类 Select类是selenium的一个特定的类,用来与下拉菜单和列表交互。 下拉菜单和列表是通过HTML的<select> 元素实现的。选择项是通过<select>中的<option>元素实现的。使用前使用下面的语句导入模块。 from selenium.webdriver.support.ui import Select (二) Select类的功能及方法 功能/属性 简单说明 all_selected_options 获取下拉菜单和列表中被选中的所有
free赖权华
2018/04/27
3.3K0
Selenium Python使用技巧(二)
您可能需要在多种情况下针对不同的浏览器(例如Firefox,Chrome,Internet Explorer,Edge)测试代码。跨不同浏览器测试网站的做法称为自动浏览器测试。要使用Selenium自动化测试执行自动浏览器测试,您应该在单元测试代码或pytest代码中合并对这些浏览器的选择性处理。下面显示了一个代码片段(利用pytest)来处理多个浏览器:
FunTester
2020/02/17
6.5K0
点击加载更多

相似问题

Selenium,PHPUnit -使用xpath单击链接

40

PHPUnit Selenium的单击按钮和链接命令是什么?

11

Selenium -无法从下拉列表中单击链接

43

如何使用PHPUnit和Selenium从下拉窗口中选择链接

22

Selenium单击链接

21
添加站长 进交流群

领取专属 10元无门槛券

AI混元助手 在线答疑

扫码加入开发者社群
关注 腾讯云开发者公众号

洞察 腾讯核心技术

剖析业界实践案例

扫码关注腾讯云开发者公众号
领券
社区富文本编辑器全新改版!诚邀体验~
全新交互,全新视觉,新增快捷键、悬浮工具栏、高亮块等功能并同时优化现有功能,全面提升创作效率和体验
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
查看详情【社区公告】 技术创作特训营有奖征文