fighting layout bugs (webinale 2011)

95
Michael Tamm | optivo GmbH Fighting Layout Bugs

Upload: michael-tamm

Post on 07-Dec-2014

1.783 views

Category:

Technology


2 download

DESCRIPTION

German presentation about automatic detection of layout bugs in web pages.

TRANSCRIPT

Page 1: Fighting Layout Bugs (webinale 2011)

Michael Tamm | optivo GmbH

Fighting Layout Bugs

Page 2: Fighting Layout Bugs (webinale 2011)

2 / 95

Worum geht's?• 2 Folien Einführung• Drei alte bekannte Gegenmaßnahmen• Neue innovative Gegenmaßnahmen

Page 3: Fighting Layout Bugs (webinale 2011)

3 / 95

Wer bin ich?

Michael Tamm

SystemarchitektQA Automation ExpertSelenium CommitterConference SpeakerAutor für die c't und iX

Page 4: Fighting Layout Bugs (webinale 2011)

4 / 95

Drei-Schichten-Architektur

Presentation Layer

Business Logic Layer

Persistence Layer

Page 5: Fighting Layout Bugs (webinale 2011)

5 / 95

Worum geht's?• 2 Folien Einführung• Drei alte bekannte Gegenmaßnahmen• Neue innovative Gegenmaßnahmen

Page 6: Fighting Layout Bugs (webinale 2011)

6 / 95

Idee #1

Layout-Fehler vermeiden, indem man immer

valides HTML ausliefert.

Page 7: Fighting Layout Bugs (webinale 2011)

7 / 95

Wie?• Browser Extension

– Funktioniert nur in einem Browser– Läßt den CI-Build nicht fehlschlagen

Page 8: Fighting Layout Bugs (webinale 2011)

8 / 95

Wie?• Automatische Validierung

als Bestandteil des CI-Builds– Option 1: Ein separater Test, der die

entscheidenen Seiten Ihrer Website überprüft.

– Option2: Innerhalb bereits existierender Frontend-Tests

Page 9: Fighting Layout Bugs (webinale 2011)

9 / 95

W3C Markup Validation Service

Page 10: Fighting Layout Bugs (webinale 2011)

10 / 95

W3C Markup Validation Service

Page 11: Fighting Layout Bugs (webinale 2011)

11 / 95

W3C Markup Validation Service

Page 12: Fighting Layout Bugs (webinale 2011)

12 / 95

W3C Markup Validation Service

Page 13: Fighting Layout Bugs (webinale 2011)

13 / 95

Schnelleres Feedback möglich?

Page 14: Fighting Layout Bugs (webinale 2011)

14 / 95

Schnelleres Feedback möglich!

• Mit einem javax.servlet.Filter– Voraussetzung: HTML-Entwickler

benutzt Tomcat oder Jetty– Funktioniert in allen Browsern

Page 15: Fighting Layout Bugs (webinale 2011)

15 / 95

W3CMarkupValidationFilter

Page 16: Fighting Layout Bugs (webinale 2011)

16 / 95

Demo

Page 17: Fighting Layout Bugs (webinale 2011)

17 / 95

Demo

Page 18: Fighting Layout Bugs (webinale 2011)

18 / 95

Demo

Page 19: Fighting Layout Bugs (webinale 2011)

19 / 95

Demo

Page 20: Fighting Layout Bugs (webinale 2011)

20 / 95

Demo

Page 21: Fighting Layout Bugs (webinale 2011)

21 / 95

Ads

• Müssen Sie invalides HTML von externen Quellen in Ihre Seiten einbinden?

• Option 1: Fügen Sie einen Switch zum Ausschalten aller Ads zu Ihrer Web-applikation hinzu.

• Option 2: Erweitern Sie den W3CMarkupValidationFilter so, dass er vor der Validierung alle Ads entfernt.

Page 22: Fighting Layout Bugs (webinale 2011)

22 / 95

Page 23: Fighting Layout Bugs (webinale 2011)

23 / 95

Idee #2

Layout-Fehler vermeiden, indem man immer

valides CSS ausliefert.

Page 24: Fighting Layout Bugs (webinale 2011)

24 / 95

CSS Validation Service

Page 25: Fighting Layout Bugs (webinale 2011)

25 / 95

Page 26: Fighting Layout Bugs (webinale 2011)

26 / 95

Page 27: Fighting Layout Bugs (webinale 2011)

27 / 95

Idee #3

Layout-Fehler vermeiden, indem man auf gültigeBild-URLs überprüft.

Page 28: Fighting Layout Bugs (webinale 2011)

28 / 95

DetectInvalidImageUrls

• Überprüft HTML auf sichtbare<img>- Elemente ohne oder mit ungültigen src-Attribut

• Überprüft CSS (style-Attribute,<style>-Elemente, eingebundeneStylesheets) auf ungültige Bild-URLs

• Überprüft die URL für das Favicon

http://fighting-layout-bugs.googlecode.com

Page 29: Fighting Layout Bugs (webinale 2011)

29 / 95

Page 30: Fighting Layout Bugs (webinale 2011)

30 / 95

Worum geht's?• 2 Folien Einführung• Drei alte bekannte Gegenmaßnahmen• Neue innovative Gegenmaßnahmen

Page 31: Fighting Layout Bugs (webinale 2011)

31 / 95

Page 32: Fighting Layout Bugs (webinale 2011)

32 / 95

Page 33: Fighting Layout Bugs (webinale 2011)

33 / 95

Page 34: Fighting Layout Bugs (webinale 2011)

34 / 95

Page 35: Fighting Layout Bugs (webinale 2011)

35 / 95

Page 36: Fighting Layout Bugs (webinale 2011)

36 / 95

Page 37: Fighting Layout Bugs (webinale 2011)

37 / 95

Page 38: Fighting Layout Bugs (webinale 2011)

38 / 95

Page 39: Fighting Layout Bugs (webinale 2011)

39 / 95

Page 40: Fighting Layout Bugs (webinale 2011)

40 / 95

Idee #4

Layout-Fehler entdecken, indem man die menschliche

Wahrnehmung simuliert.

Page 41: Fighting Layout Bugs (webinale 2011)

41 / 95

Page 42: Fighting Layout Bugs (webinale 2011)

42 / 95

Page 43: Fighting Layout Bugs (webinale 2011)

43 / 95

Page 44: Fighting Layout Bugs (webinale 2011)

44 / 95

Page 45: Fighting Layout Bugs (webinale 2011)

45 / 95

Page 46: Fighting Layout Bugs (webinale 2011)

46 / 95

Page 47: Fighting Layout Bugs (webinale 2011)

47 / 95

SimpleTextDetector

• jQuery wird in die zu analysierende Seite injected• jQuery('*').css('color', '#000000');• ein Screenshot wird erstellt• jQuery('*').css('color', '#fffff');• es wird ein zweiter Screenshot erstellt• Vergleich beider Screenshots:

unterschiedliche Pixel sind Textpixel

http://fighting-layout-bugs.googlecode.com

Page 48: Fighting Layout Bugs (webinale 2011)

48 / 95

Page 49: Fighting Layout Bugs (webinale 2011)

49 / 95

Page 50: Fighting Layout Bugs (webinale 2011)

50 / 95

Page 51: Fighting Layout Bugs (webinale 2011)

51 / 95

Page 52: Fighting Layout Bugs (webinale 2011)

52 / 95

SimpleEdgeDetector

• jQuery wird in die zu analysierende Seite injected• jQuery('*').css('color', 'transparent');• ein Screenshot wird erstellt• Bestimmen der Kandidaten für vertikale / horizontale

Kanten: alle Pixelpaare mit hohem Kontrast• Bestimmen der vertikale / horizontale Kanten:

alle vertikalen / horizontalen Sequenzen in dengefundenen Kandidaten mit ähnlicher Farbe undeiner gewissen Mindestlänge

http://fighting-layout-bugs.googlecode.com

Page 53: Fighting Layout Bugs (webinale 2011)

53 / 95

Page 54: Fighting Layout Bugs (webinale 2011)

54 / 95

Page 55: Fighting Layout Bugs (webinale 2011)

55 / 95

Page 56: Fighting Layout Bugs (webinale 2011)

56 / 95

Page 57: Fighting Layout Bugs (webinale 2011)

57 / 95

Demo

Page 58: Fighting Layout Bugs (webinale 2011)

58 / 95

Page 59: Fighting Layout Bugs (webinale 2011)

59 / 95

DetectTextWithTooLowContrast

http://fighting-layout-bugs.googlecode.com

• Textpixel identifizieren (wie bereits gesehen)• Überprüfen, ob Kontrast zwischen Textpixeln

und Hintergrundpixeln groß genug ist

Page 60: Fighting Layout Bugs (webinale 2011)

60 / 95

Page 61: Fighting Layout Bugs (webinale 2011)

61 / 95

http://fighting-layout-bugs.googlecode.com/

• DetectInvalidImageUrls• DetectNeedsHorizontalScrolling• DetectTextNearOrOverlappingHorizontalEdge• DetectTextNearOrOverlappingVerticalEdge• DetectTextWithTooLowContrast

Page 62: Fighting Layout Bugs (webinale 2011)

62 / 95

Integration in den Entwicklungsprozess

• Nigthly Build• Option 1: separater Frontend-Test,

der verschiedene wohldefinierteSeiten untersucht

• Option 2: An ausgewählten Punktenin bereits bestehenden Frontend-Tests

Page 63: Fighting Layout Bugs (webinale 2011)

63 / 95

Fehlerhafte Texterkennungdurch Animation auf der

zu analysierenden Seite ...

Page 64: Fighting Layout Bugs (webinale 2011)

64 / 95

Page 65: Fighting Layout Bugs (webinale 2011)

65 / 95

Page 66: Fighting Layout Bugs (webinale 2011)

66 / 95

Page 67: Fighting Layout Bugs (webinale 2011)

67 / 95

Page 68: Fighting Layout Bugs (webinale 2011)

68 / 95

Page 69: Fighting Layout Bugs (webinale 2011)

69 / 95

Umgang mit „Fehlalarmen“

• Option 1: Umkonfiguration des Kontrastschwellwerts für Kanten

Page 70: Fighting Layout Bugs (webinale 2011)

70 / 95

Page 71: Fighting Layout Bugs (webinale 2011)

71 / 95

Page 72: Fighting Layout Bugs (webinale 2011)

72 / 95

Umgang mit „Fehlalarmen“

• Option 1: Umkonfiguration des Kontrastschwellwerts für Kanten

• Option 2: Bestimmte HTML-Elemente ausschließen

Page 73: Fighting Layout Bugs (webinale 2011)

73 / 95

Weitere typische Layoutfehler ...

Page 74: Fighting Layout Bugs (webinale 2011)

74 / 95

Page 75: Fighting Layout Bugs (webinale 2011)

75 / 95

Page 76: Fighting Layout Bugs (webinale 2011)

76 / 95

Idee #5

Layout-Fehler entdecken, indem man den angezeigten Text

auf verdächtige Muster prüft.

Page 77: Fighting Layout Bugs (webinale 2011)

77 / 95

Page 78: Fighting Layout Bugs (webinale 2011)

78 / 95

Page 79: Fighting Layout Bugs (webinale 2011)

79 / 95

Page 80: Fighting Layout Bugs (webinale 2011)

80 / 95

Page 81: Fighting Layout Bugs (webinale 2011)

81 / 95

Page 82: Fighting Layout Bugs (webinale 2011)

82 / 95

Page 83: Fighting Layout Bugs (webinale 2011)

83 / 95

Page 84: Fighting Layout Bugs (webinale 2011)

84 / 95

Page 85: Fighting Layout Bugs (webinale 2011)

85 / 95

Idee #6

Layout-Fehler entdecken,indem man Screenshots von

verschiedenen Browsern vergleicht.

Page 86: Fighting Layout Bugs (webinale 2011)

86 / 95

Page 87: Fighting Layout Bugs (webinale 2011)

87 / 95

Idee #7

Zukünftige Layout-Fehler vermeiden, indem man automatische Tests fürbekannte Layout-Fehler schreibt.

Page 88: Fighting Layout Bugs (webinale 2011)

88 / 95

Page 89: Fighting Layout Bugs (webinale 2011)

89 / 95

Page 90: Fighting Layout Bugs (webinale 2011)

90 / 95

Page 91: Fighting Layout Bugs (webinale 2011)

91 / 95

Page 92: Fighting Layout Bugs (webinale 2011)

92 / 95

Page 93: Fighting Layout Bugs (webinale 2011)

93 / 95

Page 94: Fighting Layout Bugs (webinale 2011)

94 / 95

Idee #8

Layout-Fehler vermeiden, indem man aus Designvorlagen

automatische Akzeptanztests ableitet.

Page 95: Fighting Layout Bugs (webinale 2011)

95 / 95

Danke für Ihre Aufmerksamkeit• http://validator.w3.org/• http://w3c-markup-validation-filter.googlecode.com/• http://jigsaw.w3.org/css-validator/• http://selenium.googlecode.com/• http://fighting-layout-bugs.googlecode.com/

[email protected]