Selenium: Python webdriver common commands

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 […]

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: 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: ‘ + […]

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 […]