我正在尝试设置R shiny和Selenium自动化Web工具进行测试。我尝试使用selenium Shiny教程示例的提交按钮,但它不起作用。该按钮被选中,但textOutput不会更改为新的textInput值。下面我粘贴server.R,UI.R和python selenium命令。谢谢你的提示。
server.R
library(shiny)
shinyServer(function(input, output) {
output$plot1 <- renderPlot({
hist(rnorm(input$n))
})
output$text <- renderText({
paste("Input text is:", input$text)
})
})
ui.R
library(shiny)
shinyUI(fluidPage(
titlePanel("submitButton example"),
fluidRow(
column(3, wellPanel(
sliderInput("n", "N:", min = 10, max = 1000, value = 200,
step = 10),
textInput("text", "Text:", "text here"),
HTML("<button id='submitid' type='submit'>Submit</button>")
)),
column(6,
plotOutput("plot1", width = 400, height = 300),
verbatimTextOutput("text")
)
)
))
我的python selenium命令:
from selenium import webdriver
driver = webdriver.Firefox()
driver.get("http://127.0.0.1:8010/")
driver.execute_script("document.getElementById('text').setAttribute('value', 'aaa')");
submit=driver.find_element_by_id("submitid")
submit.click()