添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
善良的稀饭  ·  育罢不能 | ...·  6 月前    · 
快乐的黑框眼镜  ·  Math.round in ...·  1 年前    · 
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I am trying to login to a website using AjaxForm. I managed to retine the forms and reach the xpath of the desired button though when I call #click I get this error:

EcmaError: lineNumber=[193] column=[0] lineSource=[<no source>] name=[ReferenceError] sourceName=[script in https://test.paypo.com/Account/Login?ReturnUrl=%2FHome%2FStart from (177, 32) to (221, 10)]
 message=[ReferenceError: "Paypo" is not defined.
 (script in https://test.paypo.com/Account/Login?ReturnUrl=%2FHome%2FStart from (177, 32) to (221, 10)#193)] 
com.gargoylesoftware.htmlunit.ScriptException: ReferenceError: "Paypo" is not defined. (script in https://test.paypo.com/Account/Login?ReturnUrl=%2FHome%2FStart from (177, 32) to (221, 10)#193)

I am honestly clueless on how to get around this... important note is that I have no access to the source of the website, the actual website logging works perfectly fine. I've tried using any kind of BrowserVersion and different HtmlUnit versions...

Current code:

                final HtmlPage thePage = ((HtmlPage) page);
                final HtmlButtonInput button = (HtmlButtonInput) thePage.getByXPath("//input[@type='button']").get(0);
                webClient.getOptions().setThrowExceptionOnScriptError(true);
                final HtmlPage newPage = button.click();

Error araises when #click is called!

Any clue? Please!

Please check first if you get the same error when doing the same action with your browser. And provide a more complete sample code, at least the url you are calling.... – RBRi Nov 19, 2018 at 18:24 I receive no error. @RBRi, though if you'd check you would see that the link is inside the error: test.paypo.com/Account/Login?ReturnUrl=%2FHome%2FStart thank you for your interest! – Tyrant Ist Nov 20, 2018 at 10:16

Ok have done a short check with this code:

final String url = "https://test.paypo.com/Account/Login?ReturnUrl=%2FHome%2FStart";
try (final WebClient webClient = new WebClient(BrowserVersion.FIREFOX_60)) {
    HtmlPage page = webClient.getPage(url);

Running this produces a bunch of errors; the first one is

com.gargoylesoftware.htmlunit.ScriptException: identifier is a reserved word: class (https://test.paypo.com/bundles/SharedJS?v=qrYYsvxJCv4nRnx8xzi1sMLBQPQlIPteJjoj8eCO1go1#7)

What does this mean?

  • The page includes some js code from the url https://test.paypo.com/bundles/SharedJS?v=qrYYsvxJCv4nRnx8xzi1sMLBQPQlIPteJjoj8eCO1go1 and there is a problem with this code. In detail the code uses the javascript 'class' language feature and HtmlUnit (in the end Rhino) does not support this syntax in the current version

  • Because of this the javascript from this external resource is not 'compilable' and thereof not available for the other javascript on that page

  • And finally this leads to the error you are facing.

  • how'd i go about that? i've got this import org.openqa.selenium.htmlunit.HtmlUnitDriver; – Tyrant Ist Nov 25, 2018 at 23:59

    Thanks for contributing an answer to Stack Overflow!

    • Please be sure to answer the question. Provide details and share your research!

    But avoid

    • Asking for help, clarification, or responding to other answers.
    • Making statements based on opinion; back them up with references or personal experience.

    To learn more, see our tips on writing great answers.