Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法使用Selenium WebDriver单击两个“继续跨度”按钮_Selenium_Webdriver - Fatal编程技术网

无法使用Selenium WebDriver单击两个“继续跨度”按钮

无法使用Selenium WebDriver单击两个“继续跨度”按钮,selenium,webdriver,Selenium,Webdriver,我试图用下面的HTML代码单击两个按钮 一, 我尝试了几个代码,但得到的错误是按钮无法点击 请协助代码查找此元素,然后单击以转到下一页 driver.findElement(By.xpath("//span[contains(text(), 'Continue Booking')])[1]/following::button[1]")).click(); log.debug("Click Continue "); WebElement elementa= driver.findE

我试图用下面的HTML代码单击两个按钮

一,

我尝试了几个代码,但得到的错误是按钮无法点击

请协助代码查找此元素,然后单击以转到下一页

driver.findElement(By.xpath("//span[contains(text(), 'Continue Booking')])[1]/following::button[1]")).click();
   log.debug("Click Continue ");




WebElement elementa=  driver.findElement(By.xpath("//span[text()='Continue Booking']/"));   
    JavascriptExecutor executore = (JavascriptExecutor) driver;
    executore.executeScript("arguments[0].click();", elementa);
org.openqa.selenium.InvalidSelectorException:无效选择器:无法 要查找xpath表达式为//span[contains(text())的元素,请执行以下操作:, “继续预订”)][1]/following::button[1]因为以下原因 错误:SyntaxError:未能对“文档”执行“评估”:文档 字符串“//span[包含(text(),”是否继续 Booking')][1]/following::button[1]'不是有效的XPath表达式。 (会话信息:chrome=74.0.3729.157)(驾驶员信息: 色度驱动=74.0.3729.6 (255758ECCF3D24491B8A1317AA76E1CE10D57E9参考文献/分支机构负责人/3729{29}),平台=窗口 NT 10.0.17763 x86_64)(警告:服务器未提供任何 堆栈跟踪信息)命令持续时间或超时:0毫秒 有关此错误的文档,请访问: 生成信息:版本:“未知”,版本:“未知”,时间:“未知” 系统信息:主机:“WN-HQ-LT-DEV-42”,ip:“10.10.11.250”,操作系统名称: 'Windows 10',os.arch:'amd64',os.version:'10.0',java.version: “1.8.0_211”驱动程序信息:org.openqa.selenium.chrome.ChromeDriver 能力{AcceptInsureCerts:false,acceptSslCerts:false, applicationCacheEnabled:false,browserConnectionEnabled:false, 浏览器名称:chrome,chrome:{chromedriverVersion:74.0.3729.6 (255758eccf3d24…,userDataDir:C:\Users\ADEYIN~1.ALA\AppDa…), CSSSelectorEnabled:true,databaseEnabled:false,goog:chromeOptions: {debuggerAddress:localhost:64341},handlesAlerts:true, hasTouchScreen:false,javascriptEnabled:true, locationContextEnabled:true,mobileEmulationEnabled:false, nativeEvents:true,networkConnectionEnabled:false,pageLoadStrategy: 普通,平台:XP,平台名称:XP,代理:proxy(),可旋转: false,setWindowRect:true,StrictFileInteractivity:false, takesHeapSnapshot:true,takesScreenshot:true,超时:{隐式: 0,页面加载:300000,脚本:30000},意外的AlertBehaviour:ignore, 未处理的PromptBehavior:忽略,版本:74.0.3729.157, WebStorage Enabled:true}会话ID:aebe53b2f0ce483db0acf2034848ecd9 ***元素信息:{Using=xpath,value=//span[contains(text(),'Continue Booking')][1]/following::button[1]}


使用
WebdriverWait
处理动态元素并遵循
Xpath

WebDriverWait wait = new WebDriverWait(driver, 30);
WebElement element = wait.until(ExpectedConditions.elementToBeClickable(By.xpath('//button[@id="cont_to_ins"]/span[contains(.,"Continue Booking")]')));
element.click()

您没有编写正确的XPath

driver.findelelement(By.xpath((//span[contains(text(),'Continue Booking'))[1]/following::button[1])。单击();
log.debug(“单击继续”)

请花几分钟时间将问题正确格式化。代码应格式化为代码,错误消息可以格式化为代码或引号。如果需要有关格式化的帮助,请在进入编辑器时参阅格式化帮助。谢谢。另外,如果你想帮助构建一个新的定位器,我们需要相关的HTML。阅读异常,你就会知道为什么它不起作用,它就写在那里!
driver.findElement(By.xpath("//span[contains(text(), 'Continue Booking')])[1]/following::button[1]")).click();
   log.debug("Click Continue ");




WebElement elementa=  driver.findElement(By.xpath("//span[text()='Continue Booking']/"));   
    JavascriptExecutor executore = (JavascriptExecutor) driver;
    executore.executeScript("arguments[0].click();", elementa);
WebDriverWait wait = new WebDriverWait(driver, 30);
WebElement element = wait.until(ExpectedConditions.elementToBeClickable(By.xpath('//button[@id="cont_to_ins"]/span[contains(.,"Continue Booking")]')));
element.click()