javascript - 如果使用 node js 和 yarn 单击按钮,我应该如何开始在 src/test/file.me 中编写代码?
问题描述
我在 src/components/Introduction.jsx 文件中有以下代码,我还没有创建它并希望进一步处理它。
import RaisedButton from 'material-ui/RaisedButton';
import Paper from 'material-ui/Paper';
import { Img } from 'react-image';
import React from 'react';
import logo from '../logo.png';
const paperStyle = {
padding: 20,
height: 6000,
margin: 20,
alignItems: 'center',
textAlign: 'center',
backgroundColor: '#ced7e5',
};
const Logo = () => <Img src={logo} />;
const Introduction = props => (
<section id="home">
<Paper style={paperStyle} zDepth={3}>
<Logo />
<h1 className="title">Welcome</h1>
<p className="intro">
Using the programming language of your choice we want you to create a selenium framework
in .src/test/e2e.Use selenium to click the button below to continue with the test.
</p>
<RaisedButton data-test-id="render-challenge" label="Render the Challenge" primary onClick={props.showChallenge} />
<p>You might have noticed that clicking that button starts a really, really long scroll. </p>
<p>I wonder how you are going to handle that? </p>
<span style={{ fontSize: 60 }} role="img" aria-label="down-emoj" >⬇�</span>
</Paper>
</section>
);
export default Introduction;
我想点击RENDER THE CHALLENGE按钮。我认为已经有一种方法可以单击此 Introduction.jsx 文件中的RENDER THE CHALLENGE按钮。我的问题是我需要在 src/test/e2e/implement.me 文件中写一些东西吗?如果是,那又如何?还是props刚刚定义了页面布局上的对象?实际点击应该在 src/test/e2e/implement.me 文件中完成? 按钮图片
我有以下配置:
我正在使用yarn start执行脚本。所以我的问题是我应该在 implement.me 文件中添加什么代码来单击按钮。还是我需要在文件夹中配置 Selenium Webdriver?
解决方案
通过此 Xpath 表达式查找元素:
//*[contains(text(),'RENDER THE CHALLENGE')]
WebElement we = browser.findElement(By.xpath(xPath));
we.click();
推荐阅读
- php - 在 LEFT JOIN 之后从单个数据库条目中回显多个值以从不同的表中提取名称
- java - 在 Java 中,允许程序向 CMD.exe 发送命令的小帮助
- mysql - 如何从表中找到每个值的唯一计数?
- .net - 如何避免 sql server 代理中的凭据弹出 powershell 窗口?
- powershell - 列出 PowerShell 中的所有服务
- ruby - 我有一个带有参数的对象数组(在哈希中)。如何列出每个对象的所有参数?
- html - 为什么那个边框不覆盖它的内容
- java - 如何清理带有太多 if/else java 的代码
- python - 安装 tensorflow 时出现 Pip 错误:没有磁盘空间
- cookies - 如何在 ASP.NET 4.6.1 及以下版本中支持 SameSite Cookie