TIT
(Сергей Блохин)
10.Октябрь.2016 11:44:39
#1
На странице есть перенаправление redirect
средствами JavaScript
.
↓
<script>
window.location.replace('http://example.com');
// or
window.location = 'http://example.com';
</script>
Связкой Ruby
+ Selenium WebDriver
+ Chrome
работает нормально, перенаправление происходит.
Связкой Ruby
+ Selenium WebDriver
+ PhantomJS
перенаправления не происходит.
Кто-нить сталкивался с подобным? Есть ли решение?
arturk
(Artur Korobeynyk)
10.Октябрь.2016 12:17:15
#2
А ошибки пытались ловить?
Мне кажется причина в политике Same Origin для защиты от CSRF. Почитайте об Access Control Allow Origin хидере HTTP. Можете попробовать добавить настройку на сервер (точнее убрать защиту с сервера)
TIT
(Сергей Блохин)
10.Октябрь.2016 12:25:47
#3
А ошибки пытались ловить?
Пытался, безуспешно. Их нет.
Можете попробовать добавить настройку на сервер (точнее убрать защиту с сервера)
Нет сервера. Локальный .html
файл с одной строчкой <script></script>
и тот не работает.
Если мой плохой английский меня не сильно подвёл, то тут
↓
opened 10:09PM - 19 Apr 14 UTC
closed 05:51PM - 29 Dec 19 UTC
stale
I have a webpage, which has a `<script>` tag with JavaScript that (conditionally… ) redirects to an URL, via `window.location = "..."`. I'm transfering Selenium tests to Phantom.js, and there are some tests which are testing that this redirect happens.
The catch is that the page this URL points to doesn't exist (I'm new to this project, so I have not understood yet why), so after I sleep wait for enough time (so that the redirected page can load), Phantom.js tells me that I'm still on the previous page. This doesn't happen if I just swap that URL with an existing one (or with Selenium).
I think it would make sense that Phantom.js still shows that URL, even though it didn't load anything (since the page doesn't exist), because that's the behaviour of regular browsers. Is this behaviour difficult to make?
opened 08:46PM - 19 Feb 12 UTC
closed 03:05PM - 23 Nov 15 UTC
Bug
_**[ctvo...@gmail.com](http://code.google.com/u/112316210031759700264/) commente… d:**_
> Version of PhantomJS: Version 1.3.0 "Water Lily".
>
> <b>What steps will reproduce the problem?</b>
> 1. I run from console:
>
> DISPLAY=:0 timeout 25 /root/phantomjs/bin/phantomjs --ignore-ssl-errors=yes /root/phantomjs/rasterize202x152.js www.chow-chow.hu /var/thumbnails/thumbfile.jpg
> or:
> DISPLAY=:0 timeout 25 /root/phantomjs/bin/phantomjs --ignore-ssl-errors=yes /root/phantomjs/rasterize202x152.js http://hfv-speyer.de /var/thumbnails/thumbfile.jpg
> 1. /root/phantomjs/rasterize202x152.js listing:
> var page = new WebPage(),
> address, output, size, rc=0;
> page.settings.userAgent = 'Mozilla/5.0 (Windows NT 5.1; rv:8.0) Gecko/20100101 Firefox/7.0';
>
> if (phantom.args.length < 2 || phantom.args.length > 3) {
> console.log('Usage: rasterize.js URL filename');
> phantom.exit();
> } else {
> address = phantom.args[0];
> output = phantom.args[1];
> page.viewportSize = { width: 1024, height: 768 }
> page.open(address, function (status) {
> if (status == 'fail') {
> console.log('Unable to load the address! ' + address);
> phantom.exit();
> console.log('Unable to load the address! ' + address);
> } else {
> window.setTimeout(function () {
> page.clipRect = { top: 0, left: 0, width: 990, height: 745 };
> page.render(output);
> console.log(status);
> phantom.exit();
> }, 200);
> }
>
> });
>
> }
>
> <b>What is the expected output? What do you see instead?</b>
> I expected to get JPEG thumbnail in /var/thumbnails/thumbfile.jpg but no file creates. For chow-chow.hu I get "success" message, and no error is shown. For hfv-speyer.de I get "Unable to load the address!" error message.
>
> <b>Which operating system are you using?</b>
> Debian GNU/Linux 2.6.32-5-686
>
> <b>Did you use binary PhantomJS or did you compile it from source?</b>
> Compiled from the source.
>
> Please provide any additional information below:
>
> It seems that PhantomJS can`t follow redirects like that on this websites: http://www.chow-chow.hu ( redirects to http://www.chow-chow.hu/start.php ) and http://hfv-speyer.de (redirects to http://www.hfv-speyer.de/js-start.htm)
> Many other websites are rendering well the same way at my server.
>
> Great thanks for developers for such awesome project! I really appreciate your work.
**Disclaimer:**
This issue was migrated on 2013-03-15 from the project's former issue tracker on Google Code, [Issue #389](http://code.google.com/p/phantomjs/issues/detail?id=389).
:star2: **13** people had starred this issue at the time of migration.
Вроде как пишут, что это беда самого PhantomJS
и пока это не лечится.