Every time I get a new job I am being thrown right into middle of the action. No tutorials, no babysitting - just a real project and a task to complete. It is a very stressful and frustrating at the beginning - but - after a short while not only I have completed the task - but also have this feeling that in a month of practice I've learned more than in a year of solving theoretical and imaginary problems. So - I've prepared an unfinished game - and a plot for you as a new employee. Let me know does it work and what was your experience with it.So here is my brach with solutions and commits for Rezonr's tasks: github
Monday, 2 November 2015
GitHub - Unifinished Asteroitds Project
Rezonr had the idea on GitHub:
Friday, 2 October 2015
[python] Running selenium2 test on packtpub website
packtpub is a site which offer free eBook everyday.
Let's allow selenium to add daily free book for us.
Automation flow:
Let's allow selenium to add daily free book for us.
Automation flow:
- Check title of new book
- Login
- Claim new book
- Go to your library
- Check title of last added book
- Compere titles
- Logout
example.py:
from selenium import webdriver
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.support.ui import WebDriverWait # available since 2.4.0
from selenium.webdriver.support import expected_conditions as EC # available since 2.26.0
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
import contextlib
# Create a new instance of the Firefox driver
driver = webdriver.Firefox()
# go to the packtpub page
driver.get("https://www.packtpub.com/packt/offers/free-learning")
driver.implicitly_wait(5)
# store new book title
newBook = driver.find_element_by_xpath('//*[@id="deal-of-the-day"]/div/div/div[2]/div[2]/h2')
nB = newBook.text + ' [eBook]'
try:
login = driver.find_element_by_xpath('//*[@id="account-bar-login-register"]/a[1]/div')
except:
print "you are logged-in"
else:
login.click()
action = webdriver.ActionChains(driver)
action.move_to_element(driver.find_element_by_xpath(
'//*[@id="email"]'
))
action.send_keys("youremail@forloging.com")
action.send_keys(Keys.TAB)
action.send_keys("yourpassword")
action.send_keys(Keys.TAB)
action.send_keys(Keys.RETURN)
action.perform()
getBook = driver.find_element_by_class_name("book-claim-token-inner")
getBook.click();
link0 = driver.find_element_by_xpath('//*[@id="account-bar-logged-in"]/a[1]/div/strong').click()
link1 = driver.find_element_by_xpath('//*[@id="left-side-menu-inner"]/div[3]/a').click()
addedBook = driver.find_element_by_xpath('//*[@id="product-account-list"]/div[1]/div[1]/div[2]/div[1]')
aB = addedBook.text
if aB == nB:
print "hurra! you added newBook " + nB
else:
print "nope"
print aB
print nB
out = driver.find_element_by_xpath('//*[@id="left-side-menu-inner"]/form/input')
out.click()
driver.quit()
Let's try it:
python example.py
Tuesday, 29 September 2015
[win][setup] selenium2 + chromedriver + javascript + python
I. What you need:
II. What you need to do:
- install python 2.7 in default directory (with adding to env PATH)
- install node.js in default(!) directory (with adding to env PATH)
- copy chromedriver to Python27/Scripts and add it to evn PATH
- run cmd as admin and:
pip install selenium npm install selenium-webdriver
example.js :
var webdriver = require('selenium-webdriver'),
By = require('selenium-webdriver').By,
until = require('selenium-webdriver').until,
driver = new webdriver.Builder().
withCapabilities(webdriver.Capabilities.chrome()).
build();
driver.get('http://www.google.com');
var element = driver.findElement(webdriver.By.name('q'));
element.sendKeys('Cheese!');
element.submit();
driver.getTitle().then(function(title) {
console.log('Page title is: ' + title);
});
driver.wait(function() {
return driver.getTitle().then(function(title) {
return title.toLowerCase().lastIndexOf('cheese!', 0) === 0;
});
}, 3000);
driver.getTitle().then(function(title) {
console.log('Page title is: ' + title);
});
driver.quit();
run the script:
node example.js
Subscribe to:
Comments (Atom)