我正在创建一个带有react,redux和next.js的项目,并想在js中导入CSS文件。
我按照next.js /#css和next-css中的说明进行操作,但是发现CSS样式无效。
我的代码如下:
pages / index.js:
import React from 'react'
import "../style.css"
class Index extends React.Component {
render() {
return (
<div className="example">Hello World!</div>
);
}
}
export default Index
Run Code Online (Sandbox Code Playgroud)
next.config.js:
const withCSS = require('@zeit/next-css')
module.exports = withCSS()
Run Code Online (Sandbox Code Playgroud)
style.css:
.example {
font-size: 50px;
color: blue;
}
Run Code Online (Sandbox Code Playgroud)
package.json:
{
"name": "my-app",
"version": "0.1.0",
"private": true,
"dependencies": {
"@zeit/next-css": "^0.1.5",
"next": "^6.0.0",
"react": "^16.3.2",
"react-dom": "^16.3.2",
"react-redux": "^5.0.7",
"react-scripts": "1.1.4",
"redux": "^4.0.0",
"redux-devtools": "^3.4.1"
},
"scripts": { …Run Code Online (Sandbox Code Playgroud) 我想测试按钮的点击行为。执行button.tap()时,测试失败。
XCTContext.runActivity(named: "Validate reply click") { (activity) in
let button = App.buttons.matching(identifier: "Reply-ok").firstMatch
button.tap()
}
Run Code Online (Sandbox Code Playgroud)
错误消息:无法合成事件:无法计算按钮的命中点,标识符:“Reply-ok”,标签:“Reply 1:ok。”:来自 AXUIElementCopyMultipleAttributeValues 的 2062、2021、2123 的辅助功能错误 kAXErrorInvalidUIElement
尝试过的解决方案:
func forceTapElement(element: XCUIElement) {
msleep(milliSeconds: 1000)
if self.isHittable {
self.tap()
}
else {
let coordinate: XCUICoordinate = self.coordinate(withNormalizedOffset: CGVector(dx: 0, dy: 0)).withOffset(CGVector(dx: element.frame.origin.x, dy: element.frame.origin.y))
coordinate.tap()
}
}
Run Code Online (Sandbox Code Playgroud)
XCTContext.runActivity(named: "Validate reply click") { (activity) in
let button = App.buttons.matching(identifier: "Reply-ok").firstMatch
if button.exists, button.isHittable {
button.tap()
}
}
Run Code Online (Sandbox Code Playgroud)
这两种解决方案都不起作用,我仍然遇到同样的错误。知道为什么会出现错误以及如何解决这个问题吗?