选择日期和时间时,Selenium Webdriver卡住了

时间:2016-07-13 15:40:34

标签: java selenium automation

我正在尝试使用Selenium测试网站。选择时间选择器和日期选择器时,Selenium通常会被停止。即使我尝试了一些睡眠时间,也没有用。

这是代码

driver.findElement(By.id("DeparturePoint")).sendKeys("New York");
driver.findElement(By.id("ArrivalPoint")).sendKeys("Paris");
driver.findElement(By.id("DepartureTime")).sendKeys("12:01 am");   
driver.findElement(By.id("ArrivalTime")).sendKeys("12:01 am");
Thread.sleep(1000); 
driver.findElement(By.id("DepartureDate")).sendKeys("07/10/2016");  
driver.findElement(By.id("ArrivalDate")).sendKeys("07/16/2016");
Thread.sleep(1000); 

以下是正在测试的网页的屏幕截图:

enter image description here

3 个答案:

答案 0 :(得分:0)

我的猜测是你需要点击每个控件以使其远离拾取器,然后你可以发送键。这假设这些控件实际上允许您在输入字段中键入字符。

答案 1 :(得分:0)

您要点击的按钮被屏蔽。 Selenium只能点击可见但未被其他元素覆盖的元素。

你可以,例如点击另一个元素来关闭日期pcikers(或根据网站自己进入图层)

driver.findElement(By.id("DeparturePoint")).click();

之后,Button应该再次可见

答案 2 :(得分:0)

c:\TAVOLI>crosswalk-pkg --platforms=windows xwalk-simple
  Packaging c:\TAVOLI\xwalk-simple
  Checking host setup
  + Checking host setup for target windows
  + Checking for candle... ...ram Files (x86)\WiX Toolset v3.10\bin\candle.exe
  + Checking for light... ...ogram Files (x86)\WiX Toolset v3.10\bin\light.exe
  Initializing build dir C:\Users\GIANCA~1\AppData\Local\Temp\AFEhAH
  + Copying app template from ...node_modules\crosswalk-app-tools\app-template
  + Loading 'windows' platform backend
  + Defaulting to download channel stable
  + Looking for latest version in crosswalk/stable
  + Fetching 'stable' versions index [##########]
  + Found version '19.49.514.4' in channel 'stable'
  + Downloading 'stable' 19.49.514.4 [##########]
  + Project template created at...ocal\Temp\AFEhAH\com.app.simple\prj\windows
  Importing web application
  + Source c:\TAVOLI\xwalk-simple
  + Destination     C:\Users\GIANCA~1\AppData\Local\Temp\AFEhAH\com.app.simple\app
  Building packages armeabi-v7a,x86
  + Loading 'windows' platform backend
  + Running 'candle -v C:\Users\GIANCA~1\AppData\Local\Temp\AFEhAH\com.app.simple\com.app.simple-0.1.0.0.wxs'
  + Running 'light -v "com.app.simple-0.1.0.0".wixobj'
*** ERROR: Unhandled error 103
  + Building package [error...]
*** ERROR: Building com.app.simple failed
  + Logfiles at C:\Users\GIANCA~1\AppData\Local\Temp\crosswalk-app-tools-com.app.simple
C:\Users\GIANCARLO\AppData\Roaming\npm\node_modules\crosswalk-app-tools\src\crosswalk-pkg:572
                throw new Error("Packaging failed");
                ^

Error: Packaging failed
at callback (C:\Users\GIANCARLO\AppData\Roaming\npm\node_modules\crosswalk-app-tools\src\crosswalk-pkg:572:27)
at Main.<anonymous> (C:\Users\GIANCARLO\AppData\Roaming\npm\node_modules\crosswalk-app-tools\src\Main.js:314:13)
at PlatformBase.<anonymous> (C:\Users\GIANCARLO\AppData\Roaming\npm\node_modules\crosswalk-app-tools\windows\lib\WinPlatform.js:288:13)
at C:\Users\GIANCARLO\AppData\Roaming\npm\node_modules\crosswalk-app-tools\windows\lib\WixSDK.js:382:9
at WixSDK.<anonymous> (C:\Users\GIANCARLO\AppData\Roaming\npm\node_modules\crosswalk-app-tools\windows\lib\WixSDK.js:431:9)
at emitTwo (events.js:87:13)
at ChildProcess.emit (events.js:172:7)
at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)`