diff --git a/.github/workflows/python-app.yaml b/.github/workflows/python-app.yaml index 7bb5759..78d3d27 100644 --- a/.github/workflows/python-app.yaml +++ b/.github/workflows/python-app.yaml @@ -17,7 +17,7 @@ jobs: - name: Install Chrome run: | wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb - wget -O chrome-linux64.zip `curl -s https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions-with-downloads.json | jq -r '.channels.Stable.downloads.chromedriver[0].url'` + wget -O chromedriver-linux64.zip `curl -s https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions-with-downloads.json | jq -r '.channels.Stable.downloads.chromedriver[0].url'` sudo rm -rf /usr/bin/chromedriver sudo mkdir /usr/bin/chromedriver sudo unzip chromedriver-linux64.zip -d /usr/bin/chromedriver diff --git a/tests/CI.py b/tests/CI.py index 6a3c864..3cbd3f5 100644 --- a/tests/CI.py +++ b/tests/CI.py @@ -5,28 +5,25 @@ from selenium.webdriver.chrome.webdriver import WebDriver from selenium.webdriver.common.by import By -from twitter_user_tweet_crawler.tweet import Tweet +from twitter_user_tweet_crawler.browser import get_browser +from twitter_user_tweet_crawler.util.config import config - -def get_browser() -> WebDriver: - chrome_options = webdriver.ChromeOptions() - chrome_options.add_argument('--blink-settings=imagesEnabled=false') - chrome_options.add_argument('--disable-remote-fonts') - chrome_options.add_argument('--disable-gpu') - chrome_options.add_argument('--no-sandbox') - chrome_options.add_argument('--headless') - driver = webdriver.Chrome(options=chrome_options) - return driver +config.load({"proxy": None, "max_threads": 2, + "header": {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, " + "like Gecko) "} + , "inject_js": "script.js", + } + ) class TestCase(unittest.TestCase): def test_spider(self): - browser = get_browser() + browser = get_browser(headless=True) browser.get('https://twitter.com/_CASTSTATION/status/1697029186777706544') sleep(20) - element = browser.find_element(By.XPATH,"//*[contains(text(), '{}')]".format('miku miku oo ee oo')) + element = browser.find_element(By.XPATH, "//*[contains(text(), '{}')]".format('miku miku oo ee oo')) browser.save_screenshot('debug.png') - self.assertIn('miku miku oo ee oo',element.get_attribute('innerHTML')) + self.assertIn('miku miku oo ee oo', element.get_attribute('innerHTML')) if __name__ == '__main__':