{"action":"created","comment":{"url":"https://api.github.com/repos/sibirtsv/Beginning/pulls/comments/92139554","pull_request_review_id":12646339,"id":92139554,"diff_hunk":"@@ -0,0 +1,157 @@\n+from selenium import webdriver\n+from selenium.webdriver.common.by import By\n+from selenium.webdriver.support.ui import WebDriverWait\n+from browsermobproxy import Server\n+from urllib.parse import urlparse\n+from PIL import Image\n+import math\n+import operator\n+from functools import reduce\n+from selenium.webdriver.support import expected_conditions as EC\n+import os\n+\n+driver_get_url = \"http://project43.wikia.com/wiki/SyntheticTests/VUAP\"\n+PATH_TO_BROWSER_MOB = r\"c:\\browsermob\\bin\\browsermob-proxy.bat\"\n+css_selector = \"#TOP_LEADERBOARD\"\n+har_search = \"video/mp4\"\n+iframe_css = '#TOP_LEADERBOARD iframe[title=\"3rd party ad content\"]'\n+screen_name_1 = \"newest_before.png\"\n+screen_name_2 = \"newest_after.png\"\n+screen_name_vid = \"video_screen.png\"\n+el_displayed_1 = \".close-ad\"\n+el_displayed_2 = \".speaker\"\n+asp_rate_css = \"#TOP_LEADERBOARD\"\n+\n+\n+def screenshot(driver, css_selector, screenshot_name):\n+    \"\"\"Make screenshot of the object\n+    example screenshot('#TOP_LEADERBOARD', \"newest.png\")\"\"\"\n+    element = driver.find_element_by_css_selector(css_selector)\n+    location = element.location\n+    size = element.size\n+    driver.save_screenshot(screenshot_name)\n+    im = Image.open(screenshot_name)\n+    left = location['x']\n+    top = location['y']\n+    right = location['x'] + size['width']\n+    bottom = location['y'] + size['height']\n+    im = im.crop((left, top, right, bottom))\n+    return im.save(screenshot_name)\n+\n+\n+def compare_screenshot(screen_name_1, screen_name_2):\n+    \"\"\" Compare two screenshot from local folder\n+    example compare_screenshot(\"newest.png\", \"screen_before.png\")\"\"\"\n+    h1 = Image.open(screen_name_1).histogram()\n+    h2 = Image.open(screen_name_2).histogram()\n+    rms = math.sqrt(reduce(operator.add,\n+                           map(lambda a, b: (a - b) ** 2, h1, h2)) / len(h1))\n+    return rms == 0.0\n+\n+\n+def aspect_ratio(driver, picture_css):\n+    \"\"\" Find aspect ratio of the element(image)\n+    example aspect_ratio(\"#TOP_LEADERBOARD\", \"1\")\"\"\"\n+    image = driver.find_element_by_css_selector(picture_css)\n+    size = image.size\n+    asp_rat_numb = size['width'] / size['height']\n+    return asp_rat_numb\n+\n+\n+def element_displayed(wait, visible_element_by_css):\n+    \"\"\"Show visibility for chosen objects\n+    example element_displayed(\"#ca-ve-edit\", \"visible_1\")\"\"\"\n+    visible_elem = wait.until(EC.visibility_of_element_located(\n+        (By.CSS_SELECTOR, visible_element_by_css)))\n+    return visible_elem.is_displayed()\n+\n+\n+def condition(driver):\n+    \"\"\"Waiting for the video end\"\"\"\n+    asp_1 = aspect_ratio(driver, \"#TOP_LEADERBOARD\")\n+    return asp_1 == 2.4572192513368982\n+\n+\n+# Start\n+\n+def main():\n+    # Start options\n+    server = Server(PATH_TO_BROWSER_MOB)\n+    server.start()\n+    proxy = server.create_proxy()\n+    proxy.new_har()\n+\n+    chrome_options = webdriver.ChromeOptions()\n+    url = urlparse(proxy.proxy).path\n+    chrome_options.add_argument('--proxy-server=%s' % url)\n+    driver = webdriver.Chrome(chrome_options=chrome_options)\n+    wait = WebDriverWait(driver, 20)\n+    driver.get(driver_get_url)\n+\n+    # Make 1st screenshot\n+    screenshot(driver, css_selector, \"newest_before.png\")\n+\n+    # Calculate aspect ratio of 1st image\n+    asp_1 = aspect_ratio(driver, asp_rate_css)\n+    print(\"aspect_ratio_before \", asp_1)\n+\n+    # Cheking 1st har for video element\n+    result_1 = har_search in str(proxy.har)\n+    assert not result_1\n+    print(\"har_1\", result_1)\n+\n+    # Enter iframe and start video\n+    ifrm = driver.find_element_by_css_selector(iframe_css)\n+    driver.switch_to.frame(ifrm)\n+    driver.find_element_by_id('button').click()\n+\n+    # Quit iframe\n+    driver.switch_to_default_content()\n+\n+    # Cheking visibility of the objects\n+    close_b = element_displayed(wait, el_displayed_1)\n+    volume_b = element_displayed(wait, el_displayed_2)\n+    assert close_b\n+    assert volume_b\n+    print(\"element_displayed \", close_b)\n+    print(\"element_displayed \", volume_b)\n+\n+    # Make screenshot of video\n+    screenshot(driver, css_selector, screen_name_vid)","path":"main.py","position":120,"original_position":120,"commit_id":"091ea401e53190de1fed0cbf7dc02935d03da6cd","original_commit_id":"091ea401e53190de1fed0cbf7dc02935d03da6cd","user":{"login":"drets","id":6199462,"avatar_url":"https://avatars.githubusercontent.com/u/6199462?v=3","gravatar_id":"","url":"https://api.github.com/users/drets","html_url":"https://github.com/drets","followers_url":"https://api.github.com/users/drets/followers","following_url":"https://api.github.com/users/drets/following{/other_user}","gists_url":"https://api.github.com/users/drets/gists{/gist_id}","starred_url":"https://api.github.com/users/drets/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/drets/subscriptions","organizations_url":"https://api.github.com/users/drets/orgs","repos_url":"https://api.github.com/users/drets/repos","events_url":"https://api.github.com/users/drets/events{/privacy}","received_events_url":"https://api.github.com/users/drets/received_events","type":"User","site_admin":false},"body":"We don't use screenshot of video therefore we don't need this line.","created_at":"2016-12-13T10:32:04Z","updated_at":"2016-12-13T10:32:04Z","html_url":"https://github.com/sibirtsv/Beginning/pull/3#discussion_r92139554","pull_request_url":"https://api.github.com/repos/sibirtsv/Beginning/pulls/3","_links":{"self":{"href":"https://api.github.com/repos/sibirtsv/Beginning/pulls/comments/92139554"},"html":{"href":"https://github.com/sibirtsv/Beginning/pull/3#discussion_r92139554"},"pull_request":{"href":"https://api.github.com/repos/sibirtsv/Beginning/pulls/3"}}},"pull_request":{"url":"https://api.github.com/repos/sibirtsv/Beginning/pulls/3","id":97530677,"html_url":"https://github.com/sibirtsv/Beginning/pull/3","diff_url":"https://github.com/sibirtsv/Beginning/pull/3.diff","patch_url":"https://github.com/sibirtsv/Beginning/pull/3.patch","issue_url":"https://api.github.com/repos/sibirtsv/Beginning/issues/3","number":3,"state":"open","locked":false,"title":"Webdriver","user":{"login":"sibirtsv","id":22667349,"avatar_url":"https://avatars.githubusercontent.com/u/22667349?v=3","gravatar_id":"","url":"https://api.github.com/users/sibirtsv","html_url":"https://github.com/sibirtsv","followers_url":"https://api.github.com/users/sibirtsv/followers","following_url":"https://api.github.com/users/sibirtsv/following{/other_user}","gists_url":"https://api.github.com/users/sibirtsv/gists{/gist_id}","starred_url":"https://api.github.com/users/sibirtsv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sibirtsv/subscriptions","organizations_url":"https://api.github.com/users/sibirtsv/orgs","repos_url":"https://api.github.com/users/sibirtsv/repos","events_url":"https://api.github.com/users/sibirtsv/events{/privacy}","received_events_url":"https://api.github.com/users/sibirtsv/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-12-12T10:49:05Z","updated_at":"2016-12-13T10:32:16Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f108329e91f0f841cf8baab7d46e1f105f25b31a","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/sibirtsv/Beginning/pulls/3/commits","review_comments_url":"https://api.github.com/repos/sibirtsv/Beginning/pulls/3/comments","review_comment_url":"https://api.github.com/repos/sibirtsv/Beginning/pulls/comments{/number}","comments_url":"https://api.github.com/repos/sibirtsv/Beginning/issues/3/comments","statuses_url":"https://api.github.com/repos/sibirtsv/Beginning/statuses/091ea401e53190de1fed0cbf7dc02935d03da6cd","head":{"label":"sibirtsv:webdriver","ref":"webdriver","sha":"091ea401e53190de1fed0cbf7dc02935d03da6cd","user":{"login":"sibirtsv","id":22667349,"avatar_url":"https://avatars.githubusercontent.com/u/22667349?v=3","gravatar_id":"","url":"https://api.github.com/users/sibirtsv","html_url":"https://github.com/sibirtsv","followers_url":"https://api.github.com/users/sibirtsv/followers","following_url":"https://api.github.com/users/sibirtsv/following{/other_user}","gists_url":"https://api.github.com/users/sibirtsv/gists{/gist_id}","starred_url":"https://api.github.com/users/sibirtsv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sibirtsv/subscriptions","organizations_url":"https://api.github.com/users/sibirtsv/orgs","repos_url":"https://api.github.com/users/sibirtsv/repos","events_url":"https://api.github.com/users/sibirtsv/events{/privacy}","received_events_url":"https://api.github.com/users/sibirtsv/received_events","type":"User","site_admin":false},"repo":{"id":70185849,"name":"Beginning","full_name":"sibirtsv/Beginning","owner":{"login":"sibirtsv","id":22667349,"avatar_url":"https://avatars.githubusercontent.com/u/22667349?v=3","gravatar_id":"","url":"https://api.github.com/users/sibirtsv","html_url":"https://github.com/sibirtsv","followers_url":"https://api.github.com/users/sibirtsv/followers","following_url":"https://api.github.com/users/sibirtsv/following{/other_user}","gists_url":"https://api.github.com/users/sibirtsv/gists{/gist_id}","starred_url":"https://api.github.com/users/sibirtsv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sibirtsv/subscriptions","organizations_url":"https://api.github.com/users/sibirtsv/orgs","repos_url":"https://api.github.com/users/sibirtsv/repos","events_url":"https://api.github.com/users/sibirtsv/events{/privacy}","received_events_url":"https://api.github.com/users/sibirtsv/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sibirtsv/Beginning","description":null,"fork":false,"url":"https://api.github.com/repos/sibirtsv/Beginning","forks_url":"https://api.github.com/repos/sibirtsv/Beginning/forks","keys_url":"https://api.github.com/repos/sibirtsv/Beginning/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sibirtsv/Beginning/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sibirtsv/Beginning/teams","hooks_url":"https://api.github.com/repos/sibirtsv/Beginning/hooks","issue_events_url":"https://api.github.com/repos/sibirtsv/Beginning/issues/events{/number}","events_url":"https://api.github.com/repos/sibirtsv/Beginning/events","assignees_url":"https://api.github.com/repos/sibirtsv/Beginning/assignees{/user}","branches_url":"https://api.github.com/repos/sibirtsv/Beginning/branches{/branch}","tags_url":"https://api.github.com/repos/sibirtsv/Beginning/tags","blobs_url":"https://api.github.com/repos/sibirtsv/Beginning/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sibirtsv/Beginning/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sibirtsv/Beginning/git/refs{/sha}","trees_url":"https://api.github.com/repos/sibirtsv/Beginning/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sibirtsv/Beginning/statuses/{sha}","languages_url":"https://api.github.com/repos/sibirtsv/Beginning/languages","stargazers_url":"https://api.github.com/repos/sibirtsv/Beginning/stargazers","contributors_url":"https://api.github.com/repos/sibirtsv/Beginning/contributors","subscribers_url":"https://api.github.com/repos/sibirtsv/Beginning/subscribers","subscription_url":"https://api.github.com/repos/sibirtsv/Beginning/subscription","commits_url":"https://api.github.com/repos/sibirtsv/Beginning/commits{/sha}","git_commits_url":"https://api.github.com/repos/sibirtsv/Beginning/git/commits{/sha}","comments_url":"https://api.github.com/repos/sibirtsv/Beginning/comments{/number}","issue_comment_url":"https://api.github.com/repos/sibirtsv/Beginning/issues/comments{/number}","contents_url":"https://api.github.com/repos/sibirtsv/Beginning/contents/{+path}","compare_url":"https://api.github.com/repos/sibirtsv/Beginning/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sibirtsv/Beginning/merges","archive_url":"https://api.github.com/repos/sibirtsv/Beginning/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sibirtsv/Beginning/downloads","issues_url":"https://api.github.com/repos/sibirtsv/Beginning/issues{/number}","pulls_url":"https://api.github.com/repos/sibirtsv/Beginning/pulls{/number}","milestones_url":"https://api.github.com/repos/sibirtsv/Beginning/milestones{/number}","notifications_url":"https://api.github.com/repos/sibirtsv/Beginning/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sibirtsv/Beginning/labels{/name}","releases_url":"https://api.github.com/repos/sibirtsv/Beginning/releases{/id}","deployments_url":"https://api.github.com/repos/sibirtsv/Beginning/deployments","created_at":"2016-10-06T19:25:45Z","updated_at":"2016-10-07T19:55:09Z","pushed_at":"2016-12-13T09:59:20Z","git_url":"git://github.com/sibirtsv/Beginning.git","ssh_url":"git@github.com:sibirtsv/Beginning.git","clone_url":"https://github.com/sibirtsv/Beginning.git","svn_url":"https://github.com/sibirtsv/Beginning","homepage":null,"size":7,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"sibirtsv:master","ref":"master","sha":"565b6274a42578bc86506ff06190f9f33464973d","user":{"login":"sibirtsv","id":22667349,"avatar_url":"https://avatars.githubusercontent.com/u/22667349?v=3","gravatar_id":"","url":"https://api.github.com/users/sibirtsv","html_url":"https://github.com/sibirtsv","followers_url":"https://api.github.com/users/sibirtsv/followers","following_url":"https://api.github.com/users/sibirtsv/following{/other_user}","gists_url":"https://api.github.com/users/sibirtsv/gists{/gist_id}","starred_url":"https://api.github.com/users/sibirtsv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sibirtsv/subscriptions","organizations_url":"https://api.github.com/users/sibirtsv/orgs","repos_url":"https://api.github.com/users/sibirtsv/repos","events_url":"https://api.github.com/users/sibirtsv/events{/privacy}","received_events_url":"https://api.github.com/users/sibirtsv/received_events","type":"User","site_admin":false},"repo":{"id":70185849,"name":"Beginning","full_name":"sibirtsv/Beginning","owner":{"login":"sibirtsv","id":22667349,"avatar_url":"https://avatars.githubusercontent.com/u/22667349?v=3","gravatar_id":"","url":"https://api.github.com/users/sibirtsv","html_url":"https://github.com/sibirtsv","followers_url":"https://api.github.com/users/sibirtsv/followers","following_url":"https://api.github.com/users/sibirtsv/following{/other_user}","gists_url":"https://api.github.com/users/sibirtsv/gists{/gist_id}","starred_url":"https://api.github.com/users/sibirtsv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sibirtsv/subscriptions","organizations_url":"https://api.github.com/users/sibirtsv/orgs","repos_url":"https://api.github.com/users/sibirtsv/repos","events_url":"https://api.github.com/users/sibirtsv/events{/privacy}","received_events_url":"https://api.github.com/users/sibirtsv/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sibirtsv/Beginning","description":null,"fork":false,"url":"https://api.github.com/repos/sibirtsv/Beginning","forks_url":"https://api.github.com/repos/sibirtsv/Beginning/forks","keys_url":"https://api.github.com/repos/sibirtsv/Beginning/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sibirtsv/Beginning/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sibirtsv/Beginning/teams","hooks_url":"https://api.github.com/repos/sibirtsv/Beginning/hooks","issue_events_url":"https://api.github.com/repos/sibirtsv/Beginning/issues/events{/number}","events_url":"https://api.github.com/repos/sibirtsv/Beginning/events","assignees_url":"https://api.github.com/repos/sibirtsv/Beginning/assignees{/user}","branches_url":"https://api.github.com/repos/sibirtsv/Beginning/branches{/branch}","tags_url":"https://api.github.com/repos/sibirtsv/Beginning/tags","blobs_url":"https://api.github.com/repos/sibirtsv/Beginning/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sibirtsv/Beginning/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sibirtsv/Beginning/git/refs{/sha}","trees_url":"https://api.github.com/repos/sibirtsv/Beginning/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sibirtsv/Beginning/statuses/{sha}","languages_url":"https://api.github.com/repos/sibirtsv/Beginning/languages","stargazers_url":"https://api.github.com/repos/sibirtsv/Beginning/stargazers","contributors_url":"https://api.github.com/repos/sibirtsv/Beginning/contributors","subscribers_url":"https://api.github.com/repos/sibirtsv/Beginning/subscribers","subscription_url":"https://api.github.com/repos/sibirtsv/Beginning/subscription","commits_url":"https://api.github.com/repos/sibirtsv/Beginning/commits{/sha}","git_commits_url":"https://api.github.com/repos/sibirtsv/Beginning/git/commits{/sha}","comments_url":"https://api.github.com/repos/sibirtsv/Beginning/comments{/number}","issue_comment_url":"https://api.github.com/repos/sibirtsv/Beginning/issues/comments{/number}","contents_url":"https://api.github.com/repos/sibirtsv/Beginning/contents/{+path}","compare_url":"https://api.github.com/repos/sibirtsv/Beginning/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sibirtsv/Beginning/merges","archive_url":"https://api.github.com/repos/sibirtsv/Beginning/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sibirtsv/Beginning/downloads","issues_url":"https://api.github.com/repos/sibirtsv/Beginning/issues{/number}","pulls_url":"https://api.github.com/repos/sibirtsv/Beginning/pulls{/number}","milestones_url":"https://api.github.com/repos/sibirtsv/Beginning/milestones{/number}","notifications_url":"https://api.github.com/repos/sibirtsv/Beginning/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sibirtsv/Beginning/labels{/name}","releases_url":"https://api.github.com/repos/sibirtsv/Beginning/releases{/id}","deployments_url":"https://api.github.com/repos/sibirtsv/Beginning/deployments","created_at":"2016-10-06T19:25:45Z","updated_at":"2016-10-07T19:55:09Z","pushed_at":"2016-12-13T09:59:20Z","git_url":"git://github.com/sibirtsv/Beginning.git","ssh_url":"git@github.com:sibirtsv/Beginning.git","clone_url":"https://github.com/sibirtsv/Beginning.git","svn_url":"https://github.com/sibirtsv/Beginning","homepage":null,"size":7,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/sibirtsv/Beginning/pulls/3"},"html":{"href":"https://github.com/sibirtsv/Beginning/pull/3"},"issue":{"href":"https://api.github.com/repos/sibirtsv/Beginning/issues/3"},"comments":{"href":"https://api.github.com/repos/sibirtsv/Beginning/issues/3/comments"},"review_comments":{"href":"https://api.github.com/repos/sibirtsv/Beginning/pulls/3/comments"},"review_comment":{"href":"https://api.github.com/repos/sibirtsv/Beginning/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/sibirtsv/Beginning/pulls/3/commits"},"statuses":{"href":"https://api.github.com/repos/sibirtsv/Beginning/statuses/091ea401e53190de1fed0cbf7dc02935d03da6cd"}}}}
{"actor":{"display_login":"drets"}}