package de.scrum_master.stackoverflow
import geb.spock.GebReportingSpec
import org.openqa.selenium.By
import org.openqa.selenium.interactions.Actions
class DoubleClickTest extends GebReportingSpec {
def "double-click via Geb interaction"() {
given:
go "https://artoftesting.com/sampleSiteForSelenium.html"
def doubleClickButton = $("#dblClkBtn")
expect:
withAlert {
interact {
doubleClick(doubleClickButton)
}
} == "Hi! Art Of Testing, Here!"
}
def "double-click via Selenium action"() {
given:
go "https://artoftesting.com/sampleSiteForSelenium.html"
def doubleClickButton = driver.findElement(By.id("dblClkBtn"))
def doubleClick = new Actions(driver).doubleClick(doubleClickButton).build()
expect:
withAlert {
doubleClick.perform()
} == "Hi! Art Of Testing, Here!"
}
}
好,所以如果if语句为true,我试图将这些数字值分配给那些变量,但是当我运行程序时,它说存在语法错误。有人可以帮我解决这个问题吗?谢谢。
答案 0 :(得分:1)
您不能将运算符用作变量标识符的一部分。 Python docs about identifiers
中的完整说明 Python解释器会将+ called {wborder(0x1da6cd0,{' ' = 040},{' ' = 040},{' ' = 040},{' ' = 040},{' ' = 040},{' ' = 040},{' ' = 040},{' ' = 040})
using {' ' = 040 | {A_BOLD|A_COLOR{5 = {color8, color12}}}}, {' ' = 040 | {A_BOLD|A_COLOR{5 = {color8, color12}}}}, {' ' = 040 | {A_BOLD|A_COLOR{5 = {color8, color12}}}}, {' ' = 040 | {A_BOLD|A_COLOR{5 = {color8, color12}}}}, {' ' = 040 | {A_BOLD|A_COLOR{5 = {color8, color12}}}}, {' ' = 040 | {A_BOLD|A_COLOR{5 = {color8, color12}}}}, {' ' = 040 | {A_BOLD|A_COLOR{5 = {color8, color12}}}}, {' ' = 040 | {A_BOLD|A_COLOR{5 = {color8, color12}}}}
+ return }0
和+
标识为要执行的实际代码,而不是-
之类的变量名。
在Python以及其他编程语言中,变量标识符唯一允许使用的字符是字母(A+
,a-z
),数字(A-Z
)和下划线({{1} }。请记住,还有一条额外的规则指定您也不能以数字开头的标识符。除此之外,在Python 3中(通过PEP 3131)添加了对非ASCII字符的支持,这意味着您甚至可以用俄语(0-9
)编写变量。
我将这些变量重命名为_
,картофель = 10
或a_plus
。
答案 1 :(得分:1)
为什么不使用字典?您可以将加权和不加权的等级比例存储为等级。
{
"database": "REPLACE_WITH_DB_NAME",
"password": "REPLACE_WITH_USER",
"password": "REPLACE_WITH_PASS"
}