結論
have_selector
マッチャを用いる。
例
expect(page).to have_selector "#submit"
expect(page).not_to have_selector "#cancel"
補足
非表示要素を取り扱う際などは *options
で様々な設定が可能です。
have_selector
マッチャを用いる。
expect(page).to have_selector "#submit"
expect(page).not_to have_selector "#cancel"
非表示要素を取り扱う際などは *options
で様々な設定が可能です。
以下のような HTML があるとして、この4つの文字列を配列として扱い、期待通りであるかどうかをチェックするテストを書きたいとします。
<div class="hoge fuga">ああああ</div> <div class="hoge fuga">いいいい</div> <div class="hoge fuga">うううう</div> <div class="hoge fuga">ええええ</div>
jQuery のメソッドを使います*1。
具体的には以下のようになります。
// jQuery のオブジェクトであることが分かるように、変数名の先頭に $ を付けるのが慣習のようだ cy.get('.hoge.fuga').then(($hoge_fuga_elements) => { const texts = $hoge_fuga_elements.map((_index, item) => { // 各要素に対して jQuery の text() を実行している return Cypress.$(item).text() }) // jQuery オブジェクトのラップを外して、単なる文字列が要素となる Array にする const gotTexts = texts.get() const expectedTexts = [ 'ああああ', 'いいいい', 'うううう', 'ええええ', ] // Cypress のオブジェクトではないので expect を用いて比較している(そして配列なので deep.equal する) expect(gotTexts).to.deep.equal(expectedTexts) }) }) })
then
や each
などのコールバック関数内では注意が必要ですwrap
メソッドでラップしてあげます*1:そのために "Cypress.$" を用いています https://docs.cypress.io/api/utilities/$
*2:この表現は正確でないかもしれない
空のコマンドの配列 []
を登録する。
discord.js Guide
の こちらのページ の例でいうと、次のようになります(関連箇所だけを抜粋)。
rest.put(Routes.applicationGuildCommands(clientId, guildId), { body: [] }) .then(() => console.log('Successfully registered application commands.')) .catch(console.error);
原文では rest.put(Routes.applicationGuildCommands(clientId, guildId), { body: commands })
としているところ、空の配列を送っています。
$ ffmpeg -i input_video.mp4 -metadata title="ここに動画のタイトルが入る" -c copy output_video.mp4
確認するためには ffprobe
コマンドを用います。
$ ffprobe output_video.mp4 (省略) Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'output_video.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 title : ここに動画のタイトルが入る (省略)
metadata title=...
となっていることから想像がつくように、他のメタデータも同様にして設定できます
会員限定の生放送動画(URL が https://live.nicovideo.jp/
で始まる動画)は Streamlink を使う必要があります