2017-10-13 173 views
1

基本上我们有这个[R硒 - 表单提交按钮单击

<form action="https://audiomax.adswizz.com/api/v2/audiomax/reports/generate?type=SALES_TYPE_ID_HERE&amp;from=NUMBERS_HERE&amp;to=MORENUMBERS_HERE&amp;format=XLSX&amp;sessionID=AUTOGENERATESESSIONIDHERE" method="POST" class="ng-pristine ng-valid"> 
       <input type="hidden" name="breakdowns" ng-value="ssp_form.report_type.value" value="SALES_CHANNEL_DEAL"> 
       <!-- ngIf: ssp_form.selected_entity.id && ssp_form.selected_entity.id !== 'all' --> 
       <input type="hidden" name="format" ng-value="ssp_form.format" value="XLSX"> 
       <button type="submit" class="btn-primary btn btn-md download xh-highlight">GENERATE REPORT</button> 
      </form> 

,我可以使用类似

report <- login$findElement(using = 'xpath', "//BUTTON[@type='submit'][text()='GENERATE REPORT']") 

它正确地找到元素,但是当我尝试这样我得到:

report$clickElement() 

Selenium message:Element not found in the cache - perhaps the page has changed since it was looked up For documentation on this error, please visit: http://seleniumhq.org/exceptions/stale_element_reference.html Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03' System info: host: '92ab6929688e', ip: '172.17.0.2', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.0-93-generic', java.version: '1.8.0_91' Driver info: driver.version: unknown

Error: Summary: StaleElementReference Detail: An element command failed because the referenced element is no longer attached to the DOM. class: org.openqa.selenium.StaleElementReferenceException Further Details: run errorDetails method

我试过几乎所有的东西, 任何帮助,将不胜感激。

回答

1

您可以找到文本xptha及其me..Try工作这个

report <- login$findElement(using = 'xpath', "//button[contains(text(),'GENERATE REPORT')]") 
+0

的是,你得到这个问题? – zsbappa

+0

我得到的响应:Selenium消息:给定的选择器// [text()='GENERATE REPORT']无效或不会导致WebElement。发生以下错误: InvalidSelectorError:由于以下错误,无法找到具有xpath表达式的元素// [text()='GENERATE REPORT']: SyntaxError:该表达式不是合法表达式。 –

+0

报告< - login $ findElement(using ='xpath',“// * [text()='GENERATE REPORT']”)试试这个 – zsbappa