Upgrade to Pro — share decks privately, control downloads, hide ads and more …

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

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

Yusuke Iwaki

July 30, 2020
Tweet

More Decks by Yusuke Iwaki

Other Decks in Programming

Transcript

  1. !:VTVLF*XBLJ

    View full-size slide

  2. "CPVUNF
    w "OESPJE04վ଄԰

    ˠεϚϗΞϓϦΤϯδχΞ

    ɹˠαʔόʔαΠυΤϯδχΞ
    w 2"ͷܦݧͳ͠
    2
    ˡ͍·͜͜

    View full-size slide

  3. ࠓ೔ͷ͓࿩
    w &&ςετɺ4FMFOJVN΍$BQZCBSB͸ศརɻ
    w Ͱ΋ɺΑ͘λΠϜΞ΢τΤϥʔʹͳΔɻ
    w Ͱ΋ɺ3VCZ͔ͩΒ1VQQFUFFS +4
    ʹ৐Γ׵͑Δͷ͠ΜͲ͍
    3
    ˠQVQQFUFFSSVCZΛ࡞ͬͯɺڞଘͤͯ͞Έͨ

    View full-size slide

  4. $BQZCBSB34QFD
    4

    View full-size slide

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

    View full-size slide

  6. 1VQQFUFFS
    w XBJU'PS/BWJHBUJPO
    w ը໘ભҠ͢Δ·Ͱ଴ͭ
    w ඵܦͬͯ΋ભҠ͠ͳ͚Ε͹/BWJHBUJPO&SSPS
    w XBJU'PS4FMFDUPS
    w ಛఆͷ%0.ཁૉ͕ݱΕΔPSফ͑Δ·Ͱ଴ͭ
    w ඵ଴ͬͯ΋μϝͳΒUJNFPVUFSSPS
    11

    View full-size slide

  7. *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ͱ͔

    View full-size slide

  8. ׬ᘳ͡Όͳ͍͔ʂ

    View full-size slide

  9. ͪΐͬͱ·ͬͯʁ

    View full-size slide

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

    View full-size slide

  11. +FTU1VQQFUFFSʹҠߦ͢Ε͹͍͍ʁ
    w ॾൠͷࣄ৘ʹΑΓ
    ฒྻϥϯμϜࢼݧΛ͞ΕΔͱςετ͕௨Βͳ͍
    w ࣦഊ࣌ͷεΫϦʔϯγϣοτͱΕͳ͍
    w TNPPUIDPEFKFTUQVQQFUFFS
    w Ϟνϕʔγϣϯෆ଍ʜ
    w $BQZCBSBΛશ൱ఆ͍ͨ͠Θ͚Ͱ͸ͳ͍
    w ςετέʔε਺͕௒ͩͱɺҠߦͦͷ΋ͷ͕͠ΜͲ͍
    16

    View full-size slide

  12. ͦ͜Ͱʜ
    Puppeteer#connect

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  15. ݴޠͷนʜ
    w $BQZCBSB3VCZ
    w 1VQQFUFFS+BWB4DSJQU
    21
    page = browser.pages.first


    page.waitForSelector('#login_form')


    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide