多次使用alert.accept()无法正常运行(Using alert.accept() multiple times does not function properly)
嗨,我目前
Splinter
使用Python作为自动化QA(Splinter
)测试人员,我想做的是测试付款页面,看看是否有必要字段为空的提示并将其记录到记事本中。我的问题是,当我使用
alert.accept()
两次时,它不会第二次运行。例如:第一个提示符应该说“事务类型输入被捕获”,然后我使用
alert.accept()
来关闭提示。 但第二次它不起作用时,提示只是保持alert.accept()
当我使用alert.accept()
时不会自动单击ok按钮。 为什么是这样? 当我同时使用两个警报时,是否存在我失踪的规则?def checkTrappings(): logUtb(f, 'Checking if Transaction type is trapped, making payment with Transaction type as empty') browser.find_by_id('submitBtn').first.click() alert = browser.get_alert() x = str(alert.text) if x == 'Transaction Type is required.': logUtb(f, 'Transaction Type input is trapped') alert.accept() logUtb(f, "") logUtb(f, 'Checking if email is a valid email') browser.select('tranType','A') browser.find_by_id('submitBtn').first.click() alert = browser.get_alert() x = str(alert.text) if x == 'Please enter a valid email address.': logUtb(f, 'Proper email format is trapped') alert.accept() logUtb(f, "") browser.find_by_id('submitBtn').first.click() alert = browser.get_alert() x = str(alert.text)
logUtb
是我的功能,我将报告记录到记事本中def logUtb(fl, strx): now = datetime.datetime.now() fl.write(now.strftime('%Y-%m-%d %H:%M') + " - " + strx + "\n"); return;
我正在使用的库是碎片
Hi I am currently new to being a Automated QA (in
Splinter
) tester using Python, What I want to do is to test a payment page to see if there are prompts if the required fields are empty and log it into the notepad.My problem is that when I use
alert.accept()
twice it does not run the second time around.For example: The first prompt is expected to say "Transaction Type input is trapped" and then I use
alert.accept()
to close the prompt. But the second time around it does not work the prompt just stays where it is and does not automatically click the ok button when I usealert.accept()
. Why is this? Is there a rule i'm missing when i'm using two alerts at the same time?def checkTrappings(): logUtb(f, 'Checking if Transaction type is trapped, making payment with Transaction type as empty') browser.find_by_id('submitBtn').first.click() alert = browser.get_alert() x = str(alert.text) if x == 'Transaction Type is required.': logUtb(f, 'Transaction Type input is trapped') alert.accept() logUtb(f, "") logUtb(f, 'Checking if email is a valid email') browser.select('tranType','A') browser.find_by_id('submitBtn').first.click() alert = browser.get_alert() x = str(alert.text) if x == 'Please enter a valid email address.': logUtb(f, 'Proper email format is trapped') alert.accept() logUtb(f, "") browser.find_by_id('submitBtn').first.click() alert = browser.get_alert() x = str(alert.text)
logUtb
by the way is my function where I log the report to the notepaddef logUtb(fl, strx): now = datetime.datetime.now() fl.write(now.strftime('%Y-%m-%d %H:%M') + " - " + strx + "\n"); return;
The library i'm using is splinter
原文:https://stackoverflow.com/questions/19018444
最满意答案
默认情况下,使用
${}
语法会转义包含的文本(以帮助抵御XSS注入攻击)。相反,使用
structure:
前缀来告诉渲染引擎不要转义您的文本:<div>${structure: body}</div>
Using the
${}
syntax escapes the included text by default (to help defend against XSS injection attacks).Instead, use the
structure:
prefix to tell the rendering engine to not escape your text:<div>${structure: body}</div>
相关问答
更多-
要在金字塔中使用ZPT宏,需要通过将宏模板或宏本身传递到渲染模板(摘自文档),使宏模板本身可用于渲染模板。 from pyramid.renderers import get_renderer from pyramid.view import view_config @view_config(renderer='templates/progress.pt') def my_view(request): snippets = get_renderer('templates/macros.pt').i ...
-
处理这个问题的一个好方法是将你的account_login_widget与它自己的视图关联起来,比如: @view_config(name='login_widget', renderer='templates/account_login_widget.pt') def login_widget(request): return {'username': ...} 然后,您应该可以访问http:// yourapp / login_widget并只返回小部件的HTML。 ...
-
集成测试似乎是最好的方法,以确保您在实际渲染的场景中获得所需的内容。 你可以做的是填充模拟值,渲染模板,然后在生成的视图上运行断言。 因此,对于您的“主页”视图,您可以使用单元测试所需的'Test'填充'page_title',并首先检查模板是否呈现,然后确保视图的HTML或内容符合预期。 Integration tests seem like the best way to go in order to ensure you're getting what you want in the scenario ...
-
解决:我有一个无效的HTML文件! Solved: I had a non-valid html-file!
-
由于Chameleon 2.7.0支持load: TALES表达式,因此可以直接从另一个模板加载宏模板。 有关详细信息,请参阅@sverbois答案或此相关问题: 如何使用变色龙模板继承? 可重用模板宏教程中描述的另一种较旧的方法涉及创建一个类,该类包含需要引用并将类的实例传递到视图中的模板: class Layouts(object): @reify def global_macros(self): renderer = get_rende ...
-
间接方式(通过视图)为您提供更大的灵活性。 在一个小项目中,好处并不那么明显,但这种方法肯定会在较大的项目中得到回报。 “load:”会使你的main_template(在Zope / Plone中说话)在这里。 通过视图,它可以来自任何地方,并且可以独立于模板进行更改。 The indirect way (via view) gives you more flexibility. The benefits are not so obvious in a small project, but this ap ...
-
默认情况下,使用${}语法会转义包含的文本(以帮助抵御XSS注入攻击)。 相反,使用structure:前缀来告诉渲染引擎不要转义您的文本:${structure: body}Using the ${} syntax escapes the included text by default (to help defend against XSS injection attacks). Instead, use the structure: prefix to tell the r ...
-
对于python中的TAL条件,你可以说python:然后使用python语法条件
Maxed Out.
For TAL conditionals in python you can say python: and then use a python syntax conditional在变色龙的线断裂(Line Breaking in Chameleon)[2023-06-30]
您需要将文本分成不同的行,然后使用循环和标签渲染: ${line}
这使用str.splitlines()方法在换行符上拆分文本,然后循环在文本的每一行之后添加一个
break标记。 你在视图中没有这样做是对的,然后通过设置structure: flag强制变色龙接受你插入的
标签。 幸运的是, ...使用Chameleon ZPT渲染具有任意深度的嵌套元素(Rendering nested elements with an arbitrary depth using Chameleon ZPT)[2023-12-20]
-
ID: ${comment.id} ${comment.body}
- 两种js function 声明方式
- 如何在runtime重载javascript alert函数
- function-Oceanus配置说明
- Hadoop 异常记录 ERROR: org.apache.hadoop.hbase.MasterNotRunningException: Retried 7 times
- error C2668: 'M' : ambiguous call to overloaded function
- Solr4:Tomcat7与Solr之多核配置(Multiple Cores)
- Object Oriented Programming
- 关于对象复制时出现内容不一致的问题
- jquery ajax方法url请求action没有返回json数据。
- 请问一个jQuery的问题,谢谢
- 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
- 如何通过引用返回对象?(How is returning an object by reference possible?)
- 矩阵如何存储在内存中?(How are matrices stored in memory?)
- 每个请求的Java新会话?(Java New Session For Each Request?)
- css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
- 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
- xcode语法颜色编码解释?(xcode syntax color coding explained?)
- 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
- 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
- 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
- 西安哪有PLC可控制编程的培训
- 在Entity Framework中选择基类(Select base class in Entity Framework)
- 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
- 电脑二级VF有什么用
- Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
- 金华英语角.
- 手机软件如何制作
- 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
- 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
- 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
- Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
- 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
- python的访问器方法有哪些
- DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
- 在Ruby中对组合进行排序(Sorting a combination in Ruby)
- 网站开发的流程?
- 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
- 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
- 透明度错误IE11(Transparency bug IE11)
- linux的基本操作命令。。。
相关文章
更多最新问答
更多