プロが教えるわが家の防犯対策術!

Selenium IDEでexportしたコードをPythonで動かす方法について教えていただけませんか?

「Googleで札幌の天気を検索し、降水確率を表示する」という簡単な動作を行おうとしています。
コードを実行したところ、
import pytest
ModuleNotFoundError: No module named 'pytest'
というエラーメッセージが表示されます。

1行目の「import pytest」に問題があるというメッセージだと思いますが、
どのような処理をすると、問題をクリアできるのでしょうか?

実行したいコードは、以下になります。
どうぞよろしくお願いいたします。

import pytest
import time
import json
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

class TestSapporotenki():
def setup_method(self, method):
self.driver = webdriver.Chrome()
self.vars = {}

def teardown_method(self, method):
self.driver.quit()

def test_sapporotenki(self):

# www.google.co.jpを開く
self.driver.get("https://www.google.co.jp/")
self.driver.set_window_size(1050, 662)

# 検索ボックスに「札幌天気」を入力して、Enterキーを押す
self.driver.find_element(By.NAME, "q").send_keys("札幌天気")
self.driver.find_element(By.NAME, "q").send_keys(Keys.ENTER)

# [降水確率]のボタンをクリック
self.driver.find_element(By.ID, "wob_rain").click()

A 回答 (1件)

pytestの使い方と便利な機能:


https://qiita.com/sasaki77/items/97c90ae272373d7 …
    • good
    • 0
この回答へのお礼

ありがとう

ありがとうございます。

お礼日時:2022/02/26 18:56

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!