E
E
ertaquo2013-04-11 12:27:50
Perl
ertaquo, 2013-04-11 12:27:50

WWW::WebKit, Glib::Object::Introspection and all-all-all

There was a need to write a script that would go to the site and poke a couple of buttons. I looked in the direction of WWW::WebKit and it seemed that it was a good thing. Installed from CPAN, tried it... But alas! it didn't work.
When you run a test script from the documentation with Carp connected, it swears on the line $webkit->type("q", "hello world");like this:

undef is not of type Gtk3::WebKit::DOMXPathResult at /usr/local/lib/perl/5.14.2/Glib/Object/Introspection.pm line 59.
 at ./test.pl line 4.
  main::__ANON__('undef is not of type Gtk3::WebKit::DOMXPathResult at /usr/loc...') called at /usr/local/lib/perl/5.14.2/Glib/Object/Introspection.pm line 59
  Glib::Object::Introspection::__ANON__('Gtk3::WebKit::DOMDocument=HASH(0x36cb648)', 'q', 'Gtk3::WebKit::DOMDocument=HASH(0x36cb648)', 'Gtk3::WebKit::DOMXPathNSResolver=HASH(0x370ce88)', 7, undef) called at /usr/local/lib/perl/5.14.2/WWW/WebKit.pm line 421
  WWW::WebKit::resolve_locator('WWW::WebKit=HASH(0x1e13b60)', 'q') called at /usr/local/lib/perl/5.14.2/WWW/WebKit.pm line 594
  WWW::WebKit::type('WWW::WebKit=HASH(0x1e13b60)', 'q', 'hello world') called at ./test.pl line 12

In WWW::WebKit, this error occurs here, on the third line:
    elsif (my ($xpath) = $locator =~ /^(?: xpath=)?(.*)/xm) {
        my $resolver = $document->create_ns_resolver($context);
        my $xpath_results = $document->evaluate($xpath, $context, $resolver, ORDERED_NODE_SNAPSHOT_TYPE, undef);
        my $length = $xpath_results->get_snapshot_length;
        croak "$xpath gave $length results: " . join(', ', map $xpath_results->snapshot_item($_), 0 .. $length - 1) if $length != 1;
        return $xpath_results->snapshot_item(0);
    }

I looked on the Internet in the direction of the Glib::Object::Introspection library, and it seems like in the latest versions it was done so that variables of unknown types were replaced with NULL when passed. It seems to be what you need? I downloaded the sources from the turnips, tried to compile them. They just make && make installwent fine, but they installed a little wrong ... Well, the team make perlscolded like this:
[email protected]:~/perl-Glib-Object-Introspection$ make perl
Skip blib/arch/Glib/Object/Introspection/Install/Files.pm (unchanged)
Skip blib/lib/Glib/Object/Introspection.pm (unchanged)
Writing "Makefile.aperl" for this perl
Trying to build test libraries... not OK
Unrecognized argument in LIBS ignored: '-pthread'
Writing Makefile.aperl for Glib::Object::Introspection
Writing MYMETA.yml and MYMETA.json
make -f Makefile.aperl perl
make[1]: Вход в каталог `/home/ertaquo/perl-Glib-Object-Introspection'
Writing perlmain.c
cd . && cc -c   "-I/usr/lib/perl/5.14/CORE"  \
  -D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fstack-protector -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -g \
    -DVERSION=\"0.015\" \
  -DXS_VERSION=\"0.015\" -o perlmain.o -fPIC "-I/usr/lib/perl/5.14/CORE" perlmain.c
[ CC GObjectIntrospection.c ]
rm -rf blib/arch/auto/Glib/Object/Introspection/Introspection.a
[ AR blib/arch/auto/Glib/Object/Introspection/Introspection.a ]
chmod 755 blib/arch/auto/Glib/Object/Introspection/Introspection.a
cat blib/arch/auto/Glib/Object/Introspection/extralibs.ld >> blib/arch/auto/Glib/Object/Introspection/extralibs.all
cc -fstack-protector -L/usr/local/lib -Wl,-E -o perl -O2 -g ./perlmain.o GObjectIntrospection.o blib/arch/auto/Glib/Object/Introspection/Introspection.a /usr/lib/perl/5.14/CORE/libperl.a `cat blib/arch/auto/Glib/Object/Introspection/extralibs.all` -ldl -lm -lpthread -lc -lcrypt 
GObjectIntrospection.o: In function `get_package_for_basename':
/home/ertaquo/perl-Glib-Object-Introspection/gperl-i11n-info.c:202: undefined reference to `gperl_sv_is_defined'
GObjectIntrospection.o: In function `create_perl_callback_closure':
/home/ertaquo/perl-Glib-Object-Introspection/gperl-i11n-callback.c:9: undefined reference to `gperl_sv_is_defined'

And further on many lines with similar errors.
Has anyone come across this by chance? Is there a way to fix this or do I have to use something else?
Oh yes, Ubuntu 12.10 x64.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
W
wise_gopher, 2013-04-19
@wise_gopher

If you just poke on a "pair of buttons" can this work? Codeception->Acceptance

P
pcdesign, 2013-04-20
@pcdesign

a script that would go to the site and poke a couple of buttons.

Isn't LWP::UserAgent sufficient for this?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question