cefsharp重写默认js弹窗(alert/confirm/prompt)
1.设置js弹窗控制器
webView.JsDialogHandler = this; //js弹窗控制
this表示本类对象,所以本类要实现IJsDialogHandler接口
2.实现IJsDialogHandler接口接口方法
public bool OnJSAlert(IWebBrowser browser, string url, string message)
{
MessageBox.Show(message);
return true; //阻止js弹
} public unsafe bool OnJSConfirm(IWebBrowser browser, string url, string message, bool* retval)
{
DialogResult result = MessageBox.Show(message, "提示", MessageBoxButtons.YesNo);
bool value = result == DialogResult.Yes ? true : false;
// retval = (bool *)GCHandle.Alloc(value).AddrOfPinnedObject().ToPointer(); //获取托管内存地址,异常
// retval = &value; //改变指针失败
*retval = value;
return true;
} public unsafe bool OnJSPrompt(IWebBrowser browser, string url, string message, string defaultValue, bool* retval, ref string result)
{
//交互消息
string r = string.Empty;
this.Invoke(new Action(() =>
{
r = Microsoft.VisualBasic.Interaction.InputBox(message, "提示", defaultValue);
}));
result = r; if (result == defaultValue)
{
*retval = false;
}
else
{
*retval = true;
}
return true;
}
cefsharp重写默认js弹窗(alert/confirm/prompt)的更多相关文章
- 在Android的webview中定做js的alert,confirm和prompt对话框的方法
在Android的webview中定制js的alert,confirm和prompt对话框的方法 http://618119.com/archives/2010/12/20/199.html 1.首先 ...
- selenium python (十一)alert/confirm/prompt的处理(js中的弹出框)
webdriver中处理js所生成的alert.confirm以及prompt,采用switch_to_alert()方法定位到alert/confirm/prompt.然后使用text/accept ...
- alert/confirm/prompt 处理
webdriver 中处理JavaScript 所生成的alert.confirm 以及prompt 是很简单的.具体思路是使用switch_to_alert()方法定位到alert/confirm/ ...
- 转:python webdriver API 之alert/confirm/prompt 处理
webdriver 中处理 JavaScript 所生成的 alert.confirm 以及 prompt 是很简单的.具体思路是使用switch_to.alert()方法定位到 alert/conf ...
- Python脚本控制的WebDriver 常用操作 <二十二> 处理alert / confirm / prompt
测试用例场景 webdriver中处理原生的js alert confirm 以及prompt是很简单的.具体思路是使用switch_to.alert()方法定位到alert/confirm/prom ...
- 2.11 alert\confirm\prompt
2.11 alert\confirm\prompt 前言 不是所有的弹出框都叫alert,在使用alert方法前,先要识别出到底是不是alert.先认清楚alert长什么样子,下次碰到了,就可以用 ...
- 如何模拟alert/confirm/prompt实现阻断程序运行
场景:在执行js的时候,我们希望运行到某处,进行用户交互,根据交互的内容,运行下面的程序:下面的js程序需要用的和用户交互的内容,所以,和用户交互时,后面的程序必须停止运行 方案: 1. 原生的ale ...
- selenium自动化测试入门 Alert/Confirm/Prompt 弹出窗口处理
一.Alert/Confirm/Prompt弹出窗口特征说明 Alert弹出窗口: 提示用户信息只有确认按钮,无法通过页面元素定位,不关闭窗口无法在页面上做其他操作. Confirm 弹出窗口: 有确 ...
- Java Selenium - 几种对话框处理Alert\confirm\prompt
1. Alert , 先用常规办法定位到能触发alert的按钮 , 然后 Alert alert = driver.switchTo().alert(); alert.accept(); 如果aler ...
随机推荐
- GitHub-版本控制
GitHub的使用:注册,登录,邮箱激活,创建第一个repository.如果branch是master,修改,提交,master直接改变. 稳妥起见创建另一个branch,修改,提交,再发出pull ...
- iOS学习笔记——键盘处理
在网上找到的资料比较零散,这部分学起来感觉也有点空虚,内容就只包括隐藏键盘和键盘高度两部分 隐藏键盘其实就在我学习iOS开发的第一个程序里面已经实践过了,不过当时还懵懵懂懂,现在就了解了是什么一回事, ...
- jQuery全屏动画焦点图
效果:http://hovertree.com/texiao/jqimg/3/ 本效果使用 jquery-1.8.3.min.js,如需使用1.12.3版本,需进行修改. 全部版本jQuery下载:h ...
- 【工匠大道】svn使用总结
原文地址 SVN(Subversion)是一个自由.开源的项目源代码版本控制工具.目前,绝大多数开源软件和企业代码管理,都使用SVN作为代码版本管理软件. Subversion将文件存放在中心版本库里 ...
- mysql 添加索引 mysql 创建索引
1.添加PRIMARY KEY(主键索引) mysql>ALTER TABLE `table_name` ADD PRIMARY KEY ( `column` ) 2.添加UNIQUE(唯一索引 ...
- inline-block 空白间距问题
一. 问题 元素是inline-block属性时,会有空白间隙 二. 解决方案 1. html方式 1)将元素之间的空隙去除 <div class="space"> & ...
- 【小贴士】关于transitionEnd/animate的一个有趣故事
前言 在很久之前,我们项目有一个动画功能,功能本身很简单,便是典型的右进左出,并且带动画功能 以当时来说,虽然很简单,但是受限于框架本身的难度,就直接使用了CSS3的方式完成了功能 当时主要使用tra ...
- input checkbox 扩大点击范围
<div style="width:100%;height:100px;"><input type="checkbox" onclick=&q ...
- JavaScript基本语法(二)
上篇博文写到JavaScript的数据类型.JavaScript包括了字符串(String).数字(Number).布尔(Boolean).数组(Array).对象(Object).空(Null).未 ...
- One-Time Project Recognition
Please indicate the source if you need to repost. After implementing NetSutie for serveral companies ...