20200730_Selenium+Capybaraで不安定なテストをPuppeteerで補強してみる

 20200730_Selenium+Capybaraで不安定なテストをPuppeteerで補強してみる

6f411237444fb0f49c63baeb9c5f2a38?s=128

Yusuke Iwaki

July 30, 2020
Tweet

Transcript

  1. !:VTVLF*XBLJ

  2. "CPVUNF w "OESPJE04վ଄԰ 
 ˠεϚϗΞϓϦΤϯδχΞ 
 ɹˠαʔόʔαΠυΤϯδχΞ w 2"ͷܦݧͳ͠ 2

    ˡ͍·͜͜
  3. ࠓ೔ͷ͓࿩ w &&ςετɺ4FMFOJVN΍$BQZCBSB͸ศརɻ w Ͱ΋ɺΑ͘λΠϜΞ΢τΤϥʔʹͳΔɻ w Ͱ΋ɺ3VCZ͔ͩΒ1VQQFUFFS +4 ʹ৐Γ׵͑Δͷ͠ΜͲ͍ 3

    ˠQVQQFUFFSSVCZΛ࡞ͬͯɺڞଘͤͯ͞Έͨ
  4. $BQZCBSB 34QFD 4

  5. None
  6. None
  7. None
  8. None
  9. ࠔͬͨʜ w ͱ͖Ͳ͖ɺͳ͔ͥ%0.ཁૉΛ௫ΜͰ͘Εͳ͍ w ʮը໘ભҠʯʮ%0.มߋݕ஌ʯَ͕໳ w Ͱ΋ɺϦτϥΠॲཧΛຖ౓͸ॻ͖ͨ͘ͳ͍ʜʂ 9

  10. None
  11. 1VQQFUFFS w XBJU'PS/BWJHBUJPO w ը໘ભҠ͢Δ·Ͱ଴ͭ w ඵܦͬͯ΋ભҠ͠ͳ͚Ε͹/BWJHBUJPO&SSPS w XBJU'PS4FMFDUPS w

    ಛఆͷ%0.ཁૉ͕ݱΕΔPSফ͑Δ·Ͱ଴ͭ w ඵ଴ͬͯ΋μϝͳΒUJNFPVUFSSPS 11
  12. *OTJEF1VQQFUFFS w XBJU'PS/BWJHBUJPO w -JGFDZDMF&WFOUϕʔεͰը໘ભҠͷݕ஌ w TSDDPNNPO'SBNF.BOBHFSUT w XBJU'PS4FMFDUPS w

    .VUBUJPO0CTFSWFSϕʔεͰ%0.ͷมߋݕ஌ w TSDDPNNPO%0.8PSMEUT 12 JOJUͱ͔%0.$POUFOU-PBEFEͱ͔
  13. ׬ᘳ͡Όͳ͍͔ʂ

  14. ͪΐͬͱ·ͬͯʁ

  15. ݴޠͷน w $BQZCBSB3VCZ w 1VQQFUFFS+BWB4DSJQU 15

  16. +FTU 1VQQFUFFSʹҠߦ͢Ε͹͍͍ʁ w ॾൠͷࣄ৘ʹΑΓ ฒྻϥϯμϜࢼݧΛ͞ΕΔͱςετ͕௨Βͳ͍ w ࣦഊ࣌ͷεΫϦʔϯγϣοτͱΕͳ͍ w TNPPUIDPEFKFTUQVQQFUFFS w

    Ϟνϕʔγϣϯෆ଍ʜ w $BQZCBSBΛશ൱ఆ͍ͨ͠Θ͚Ͱ͸ͳ͍ w ςετέʔε਺͕௒ͩͱɺҠߦͦͷ΋ͷ͕͠ΜͲ͍ 16
  17. ͦ͜Ͱʜ Puppeteer#connect

  18. None
  19. ೰Έଟ͔ͬͨैདྷͷεΫϦϓτ

  20. ͜Μͳ;͏ʹॻ͚Δͱ࠷ߴʁ ैདྷͷॲཧ͸ͦͷ··

  21. ݴޠͷนʜ w $BQZCBSB3VCZ w 1VQQFUFFS+BWB4DSJQU 21 page = browser.pages.first page.waitForSelector('#login_form')

  22. None
  23. 

  24. None
  25. SVCZDEQDVQSJUF ɾ4FMFOJVNͰ͸ͳ͘GFSSVNΛϕʔεʹͨ͠$BQZCBSBυϥΠό SVCZDEQGFSSVN ɾ3VCZͰ1VQQFUFFSΛ·ͶͨϥΠϒϥϦ ɾXBJU'PS4FMFDUPS͸ ݱࡏ ະ࣮૷ ˠ4FMFOJVN $BQZCBSBͷิڧʹ͸ͳΒͳ͍ɻ 25

  26. ࢓ํ͕ͳ͍ͷͰɺࣗ෼Ͱpuppeteer-rubyΛ࡞ͬͨɻ

  27. None
  28. None
  29. None
  30. %&.0

  31. QVQQFUFFSSVCZ w 4FMFOJVN $BQZCBSBͱڞଘՄೳ w XBJU@GPS@OBWJHBUJPO XBJU@GPS@TFMFDUPS࢖͑Δ 31 ˠطଘςετͷऑ͍෦෼ΛิڧͰ͖Δʜ

  32. None
  33. /05QSPEVDUJPOSFBEZ w ࠔ͍ͬͯΔਓ͕͍ͨΒ࢖ͬͯΈ͍ͯͩ͘͞ w ͥͻϑΟʔυόοΫ͍ͩ͘͞ 33 ˠ࣮༻ʹ଱͑͏Δঢ়ଶʹͳͬͨΒόʔδϣϯʹ͠·͢

  34. αϯϓϧू IUUQTHJUIVCDPN:VTVLF*XBLJQVQQFUFFSSVCZFYBNQMFT ୯७ͳεΫϦʔϯγϣοτऔಘ IPUFMUFTUQMBOTQIFSFͷ༧໿ɾεΫϦʔϯγϣοτ

  35. ͋Γ͕ͱ͏͍͟͝·ͨ͠