我正在使用表单组件,在此表单中,我在oder中使用 DateTimePicker 和 MuiPickersUtilsProvider 来显示两个DateTime字段。一切都可以编译并运行良好,但是编写单元测试时出现了编译错误:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from time import sleep
from selenium.webdriver.common.by import By
driver = webdriver.Chrome('C:/chromedriver.exe')
def timekiller():
user = 'user'
psw = 'pass'
driver.get('http://www.mypage.com/%27)
sleep(5)
driver.find_element_by_id('slogin').click()
sleep(5)
userid = driver.find_element_by_name('username').send_keys(user)
psw = driver.find_element_by_name('password').send_keys(psw)
sleep(5)
driver.find_element_by_class_name("form-group").submit()
sleep(5)
driver.get('http://mypage.com/like?type=photo%27)
sleep(10)
driver.find_element_by_id('get_likes_button').click()
sleep(45)
driver.get('http://www.mypage.com/logout%27)
while True:
try:
timekiller()
except Exception:
driver.get('http://www.mypage.com/logout%27)
为了修复它,我创建了一个组件,并包装了 TypeError: styles$6.makeStyles is not a function
9 | import Tab from '@material-ui/core/Tab';
10 | import DateFnsUtils from '@date-io/date-fns';
> 11 | import { DateTimePicker, MuiPickersUtilsProvider } from '@material-ui/pickers';
| ^
12 |
13 | import {
14 | inputProps,
所需的Form和其他组件,但是仍然遇到相同的问题。有时从项目中删除所有对 @ material-ui / pickers 的引用,一切正常。
这是我尝试解决此问题的方法,我使用以下代码创建了包装器组件 TestWrapperComponent :
withStyles(styles)
Form组件被命名为 Form
我期望import React from 'react';
import {createMuiTheme, MuiThemeProvider} from "@material-ui/core";
import Form from '../Form';
const Theme = createMuiTheme({...});
export default withStyles(styles)(class TestWrapperComponent extends React.Component {
render() {
return <StateProvider initialState={{
displaySuccessMsg: false,
}} reducer={reducer}>
<MuiThemeProvider theme={Theme}>
<Form/>
</MuiThemeProvider>
</StateProvider>
}
});
将解决此问题,但是我没有成功。我还在整个Google上搜索,但没有发现任何有意义的内容。
答案 0 :(得分:0)
只需更新到material-ui / core v4?