gpt4 book ai didi

java - PhantomJS:page.onError - 消息:TypeError:未定义不是函数

转载 作者:太空宇宙 更新时间:2023-11-04 12:12:46 25 4
gpt4 key购买 nike

我正在构建一个工作流程,用户可以在发送查询后获取结果。在这种情况下,用户将发送肽序列,然后它将显示结果。它对于 FireFox 驱动程序运行良好,但是当我尝试使用 PhantomJS 测试 headless 浏览器时,它会抛出错误。 Selenium 版本:2.53.1PhantomJS版本:2.1.1

Java 代码:

package phantomjs;

import java.io.IOException;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.phantomjs.PhantomJSDriver;
import org.w3c.dom.DOMException;
public class ExtractData {
public static void main(String[] args) throws InterruptedException, DOMException, IOException {
String userpepseq="NLAVSQVVHK";
WebDriver drivermassive = new PhantomJSDriver();
drivermassive.get("http://exmaple.com/xyz_search.jsp");
System.out.println(drivermassive.getTitle());
WebElement searchdatapeptideseq=drivermassive.findElement(By.name("peptide"));
System.out.println(searchdatapeptideseq.isDisplayed());
searchdatapeptideseq.sendKeys(userpepseq);
WebElement datasetbutton=drivermassive.findElement(By.xpath("//button[@class='proxi-selector' and contains (@onclick,'datasets')]"));
datasetbutton.click();
System.out.println(datasetbutton.isDisplayed());
System.out.println(drivermassive.getCurrentUrl());
Thread.sleep(5000);
String sCellValuemassid = drivermassive.findElement(By.xpath(".//*[@class='result']/tbody")).getText();
System.out.println(sCellValuemassid);
drivermassive.quit();
}
}

错误:

[ERROR - 2016-09-26T23:24:35.321Z] Session [61de22a0-8440-11e6-9376-7b90c4d612ac] - page.onError - msg: TypeError: undefined is not a function (evaluating 'query.startsWith("#")')

phantomjs://platform/console++.js:263 in error
[ERROR - 2016-09-26T23:24:35.321Z] Session [61de22a0-8440-11e6-9376-7b90c4d612ac] - page.onError - stack:
onUpdate (http://exmaple.com/xyz_search.jsp:166)
updateData (http://exmaple.com/table_ss.js:411)
render (http://exmaple.com/table_ss.js:340)
selectTable (http://exmaple.com/xyz_search.jsp:285)
onclick (http://exmaple.com/xyz_search.jsp:741)
dispatchEvent (:0)
U (:119)
$ (:108)
$ (:101)
gh (:141)
sh (:152)
(anonymous function) (:152)
(anonymous function) (:152)
(anonymous function) (:153)

phantomjs://platform/console++.js:263 in error

我试图找出为什么它抛出错误而不是显示结果,但还没有运气。有人知道如何解决这个问题吗?

最佳答案

这是因为 phantomjs 的 javascript 引擎中没有 polyfill (Function.prototype.bind) 函数。现在它有了(自 2.1 起)。尝试下载latest phantomjs release .

关于java - PhantomJS:page.onError - 消息:TypeError:未定义不是函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39713918/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com