首页 > 解决方案 > 如果使用 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?

标签: javascriptjavahtmlreactjseclipse

解决方案


通过此 Xpath 表达式查找元素:

//*[contains(text(),'RENDER THE CHALLENGE')]

WebElement we = browser.findElement(By.xpath(xPath));
we.click();

推荐阅读