I keep forgetting and having to look them up: // Find an element by CSS selector: driver.find_element_by_css_selector(“.canvas-placard.back .close”).click() // Assert DOM element not present (by CSS selector): self.assert_not_present(By.CSS_SELECTOR, “.canvas-placard.front”) // Assert true or equal, and at the same time get an attribute from a DOM element: self.assertEqual(“true”, driver.find_element_by_xpath(“//select[@id=’type’]”).get_attribute(“disabled”)) // Sending stuff to input fields: self.driver.find_element_by_css_selector(“.myselector”).send_keys(“The […]
Monthly Archives: January 2013
selenium: python webdriver choosing a select box option
from selenium import webdriver from selenium.webdriver.support.ui import Select … selectBox = Select(driver.find_element_by_id(….)) selectBox.select_by_visible_text(….)
phonegap: camera in javascript! code
function testCamera() { clearPhoto(); navigator.camera.getPicture(camSuccess, allError, { quality: 50 }); } function camSuccess(imageData) { var image = document.querySelector(‘#hello_world’); image.src = “data:image/jpeg;base64,” + imageData; } function clearPhoto() { var image = document.querySelector(‘#hello_world’); image.src = “”; }
phonegap: vibrator code
function testVibrate() { navigator.notification.vibrate(2000); //milliseconds navigator.notification.beep(2); // numbr of times }
phonegap: accelerometer code
function testAccel() { navigator.accelerometer.getCurrentAcceleration(accelSuccess, allError); } function accelSuccess(acceleration) { var element = document.getElementById(‘accel’); element.innerHTML = ‘Acceleration X: ‘ + acceleration.x + ‘<br />’ + ‘Acceleration Y: ‘ + acceleration.y + ‘<br />’ + ‘Acceleration Z: ‘ + acceleration.z + ‘<br />’ + ‘Timestamp: ‘ + acceleration.timestamp + ‘<br />’; }
phonegap: geolocation code
navigator.geolocation.getCurrentPosition(geoSuccess, allError); function geoSuccess(position) { var element = document.getElementById(‘geoApi’); element.innerHTML = ‘Getting ready to print the data’; element.innerHTML = ‘Latitude: ‘ + position.coords.latitude + ‘<br />’ + ‘Longitude: ‘ + position.coords.longitude + ‘<br />’ + ‘Altitude: ‘ + position.coords.altitude + ‘<br />’ + ‘Accuracy: ‘ + position.coords.accuracy + ‘<br />’ + ‘Altitude Accuracy: ‘ + […]
Phonegap: the nuts and bolts of developing your app
Make sure you include the following listener: <script> //onDeviceReady is called when PhoneGap is initialized function onDeviceReady() { $(document).ready(function() { //Call any jQuery functions here }); } document.addEventListener(deviceready, onDeviceReady); </script>
Phonegap: avoid the build pain and suffering
Ok, part of the pain at least… You still need to own (or access to) a Mac. And to pay the $99 fee to the Gods of Apple, and all the initial stuff to gather your Apple mobile developer certificate and your provisioning file. But once you have those two, head to: https://build.phonegap.com/ and sign up […]
HTML: canvas
1) It is a good idea to use the inline “width” and “height” instead of CSS, to define the canvas size. Weird things happen if you use CSS instead. 2) Browsers that don’t support canvas will display the text inside of it instead. 3) You need to define a context before you start using it: canvas.getContext(‘2d’) […]
HTML and CSS: general site architecture and good practices
CSS organization: Base/ – reset.css (or normalize.css) – layout.css (any grid system you are throwing in goes here) – typography.css (your fonts stuff) – utilities.css (OOCSS stuff, things that may be easier to just define a class for instead of rules below, like .left { float: left}, or .mtl { margin-top: 20px } See this […]