Я пытаюсь автоматизировать несколько шагов asp письменного сайта через casperjs. Я хочу добиться успеха.CasperJS: Как заполнить форму asp
- Перейдите на страницу входа
- Заполните имя пользователя и пароль поля
- нажмите кнопку Войти
- снимок экрана страницы успеха
Но до сих пор я только способный сделать первый шаг в этом процессе. Страница просмотра исходного кода выглядит мало для меня. Большинство узлов начинаются с тега <ui:>
, и я понятия не имею об этом.
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="theme/xslt/all.xsl?build=2.0.012&theme=theme_immi" ?>
<!DOCTYPE html [ <!ENTITY nbsp " "> ]>
<ui:root title="ImmiAccount - Login" xmlns="http://www.w3.org/1999/xhtml" xmlns:html="http://www.w3.org/1999/xhtml" xmlns:ui="http://www.immi.gov.au/Namespace/UI/V1.0">
Я сначала попробовал fillSelectors()
способ отправки формы.
casper.start('https://online.immi.gov.au/lusc/login',function() {
this.echo(this.getTitle());
this.fillSelectors('#app_L2',{
'input[id="app_L2b0a0a0a3a1a"]': 'john',
'input[id="app_L2b0a0a0a3b1a"]': 'john123'
});
this.wait('2000',function(){
this.capture('formfill.png');
});
});
casper.then(function() {
// Click on 1st result link
this.click('#app_L2b0a0a0a4a');
this.wait('5000',function(){
this.capture('success.png');
})
});
получил следующее сообщение об ошибке
CasperError: Errors encountered while filling form: no field matching css selector "input[id="app_L2b0a0a0a3a1a"]" in form;
no field matching css selector "input[id="app_L2b0a0a0a3b1a"]" in form
Затем попытался с fillXPath()
casper.start('https://online.immi.gov.au/lusc/login',function() {
this.echo(this.getTitle());
this.fillXPath('#app_L2',{
'//*[@id="app_L2b0a0a0a3a1a"]': 'john',
'//*[@id="app_L2b0a0a0a3b1a"]': 'john123'
});
this.wait('2000',function(){
this.capture('formfill.png');
});
});
casper.then(function() {
// Click on 1st result link
this.click(x('//*[@id="app_L2b0a0a0a4a"]'),
this.wait('5000',function(){
this.capture('success.png');
}));
});
После Erro произошло
CasperError: Errors encountered while filling form: Unable to find field element in form: FieldNotFound: Invalid field type; only HTMLElement and NodeList are supported; Unable to find field element in form: FieldNotFound: Invalid field type; only HTMLElement and NodeList are supported
И, наконец, я попытался sendkeys()
меня чтобы заполнить поля и click()
, чтобы нажать кнопку входа в систему. Опять же, не нашел успеха. Здесь код делает это
this.sendKeys('#app_L2b0a0a0a3a1a', 'john');
this.sendKeys('#app_L2b0a0a0a3b1a', 'john123');
this.click(x('//*[@id="app_L2b0a0a0a4a"]'),
this.wait('5000',function(){
this.capture('ctrlqpass.png');
})
);
Приведенный выше код не вызывает ни ошибки, ни страницы успеха. Во всех случаях, кассовый захват снимок экрана начальной страницы. Любая помощь очень ценится. Спасибо
спасибо за пролить немного света. Позвольте мне попробовать SlimerJS и обновить здесь. – Jasnan
SlimerJS работал очень хорошо .. спасибо – Jasnan
Обратите внимание, что SlimerJS можно также запустить [без головного убора] (http://docs.slimerjs.org/current /installation.html#having-a-headless-slimerjs), если у вас есть xvfb. –