<commit_before>---
layout: post
title: Robot Packtpub
tags: robot-framework
permalink: robot-packtpub
---

Automate claim [free ebook from packtpub](https://www.packtpub.com/packt/offers/free-learning) to your packtpub account by robotframework script.

## Robot Script
{% gist 9a567b2c2f90df2d59c5 %}

## Package Requirements or [Dockerfile on Robot-packtpub Repo](https://github.com/ibotdotout/robot-packtpub)

```sh
# should work on debian/ubuntu
$ apt-get -y update
$ apt-get -y install python-dev python-pip
$ apt-get -y install xvfb firefox

$ pip install robotframework
$ pip install robotframework-selenium2library
$ pip install robotframework-xvfb
```

## How to use

```sh
# Edit {USER} and {PASSWORD} first !!!
$ pybot robot-packtpub.txt
```

## Note
- We use Xvfb Firefox for headless browser instead of PhantomJS that have some problem on docker in this case.

- You can use [Travis-CI](https://travis-ci.org) and [Nightly Builds](https://nightli.es) to run your script everyday - [See demo here](https://github.com/ibotdotout/robot-packtpub).<commit_msg>fix: recover xpath detail<commit_after>---
layout: post
title: Robot Packtpub
tags: robot-framework
permalink: robot-packtpub
---

Automate claim [free ebook from packtpub](https://www.packtpub.com/packt/offers/free-learning) to your packtpub account by robotframework script.

## Robot Script
{% gist 9a567b2c2f90df2d59c5 %}

## Package Requirements or [Dockerfile on Robot-packtpub Repo](https://github.com/ibotdotout/robot-packtpub)

```sh
# should work on debian/ubuntu
$ apt-get -y update
$ apt-get -y install python-dev python-pip
$ apt-get -y install xvfb firefox

$ pip install robotframework
$ pip install robotframework-selenium2library
$ pip install robotframework-xvfb
```

## How to use

```sh
# Edit {USER} and {PASSWORD} first !!!
$ pybot robot-packtpub.txt
```

## Note
- We use XPath to locate where button and input form are that not flexible,
  It may change when Web UI changed (XPath is Best Solution that I found).
  You can find XPath by following this video - [Quick Tip: Getting The XPath In Google Chrome](https://www.youtube.com/watch?v=vCNLPHP3E_U).

- We use Xvfb Firefox for headless browser instead of PhantomJS that have some problem on docker in this case.

- You can use [Travis-CI](https://travis-ci.org) and [Nightly Builds](https://nightli.es) to run your script everyday - [See demo here](https://github.com/ibotdotout/robot-packtpub).
{'fraction_non_alphanumeric': 0.1134780827529701, 'fraction_numerical': 0.01106104055714871, 'mean_word_length': 4.426666666666667, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 11, 'lorem ipsum': 0, 'www.': 3, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '109627', 'n_tokens_mistral': 847, 'n_tokens_neox': 806, 'n_words': 260}