Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create antmedia-samples.py #211

Merged
merged 25 commits into from
Jul 17, 2023
Merged
Changes from 7 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
20a08fe
Create antmedia-samples.py
yashtandon113 Feb 6, 2023
7f73283
Update antmedia-samples.py
yashtandon113 Feb 20, 2023
0deeac9
Merge branch 'master' into selenium
yashtandon113 Feb 28, 2023
fbe276c
Update antmedia-samples.py
yashtandon113 Mar 5, 2023
3764eaf
Merge branch 'master' into selenium
yashtandon113 Mar 5, 2023
c48898f
Update antmedia-samples.py
yashtandon113 Mar 5, 2023
2a6140e
Update antmedia-samples.py
yashtandon113 Mar 5, 2023
2ab9078
Update antmedia-samples.py
yashtandon113 Mar 18, 2023
be91c82
Update antmedia-samples.py
yashtandon113 Mar 18, 2023
5a093a3
Update antmedia-samples.py
yashtandon113 Mar 18, 2023
162a912
Update antmedia-samples.py
yashtandon113 Mar 21, 2023
466d675
Update antmedia-samples.py
yashtandon113 Mar 21, 2023
7852de5
Merge branch 'master' into selenium
yashtandon113 Mar 25, 2023
3bc1203
Update antmedia-samples.py
yashtandon113 Apr 14, 2023
7bdc34d
Merge branch 'master' into selenium
yashtandon113 Apr 14, 2023
9ff13a4
Update antmedia-samples.py
yashtandon113 Apr 14, 2023
4b99af7
Update antmedia-samples.py
yashtandon113 Apr 14, 2023
1b0def7
Update antmedia-samples.py
yashtandon113 Apr 20, 2023
55a71f4
Update antmedia-samples.py
yashtandon113 Apr 20, 2023
80ea48e
Update antmedia-samples.py
yashtandon113 Jun 19, 2023
3220810
Merge branch 'master' into selenium
yashtandon113 Jun 19, 2023
c0f3164
Update antmedia-samples.py
yashtandon113 Jun 19, 2023
d0fcbde
Update antmedia-samples.py
yashtandon113 Jun 19, 2023
cc28a1f
Update antmedia-samples.py
yashtandon113 Jun 26, 2023
1f5bda5
Update antmedia-samples.py
yashtandon113 Jul 2, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
225 changes: 225 additions & 0 deletions Selenium/antmedia-samples.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,225 @@
# Used to import the webdriver from selenium
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.options import Options
import time
import json
import requests
import subprocess

#Function to send notification to Slack
muratugureminoglu marked this conversation as resolved.
Show resolved Hide resolved
def send_slack_message(webhook_url, message, icon_emoji=":x:"):
muratugureminoglu marked this conversation as resolved.
Show resolved Hide resolved
payload = {
"text": message,
"icon_emoji": icon_emoji
}
response = requests.post(webhook_url, data={"payload": json.dumps(payload)})
muratugureminoglu marked this conversation as resolved.
Show resolved Hide resolved

if response.status_code != 200:
print("Error sending Slack message: ", response.text)
else:
print("Slack message sent successfully!")

#Function to define and run FFMPEG
def publish_with_ffmpeg(output, rtmp_url):

# Start FFmpeg process
ffmpeg_command = ['ffmpeg', '-re', '-f', 'lavfi', '-i', 'smptebars', '-c:v', 'libx264', '-preset', 'veryfast', '-tune', 'zerolatency', '-profile:v', 'baseline']
ffmpeg_command += ['-c:a', 'aac', '-b:a', '128k', '-t', '30', '-f', output, rtmp_url]

ffmpeg_process = subprocess.run(ffmpeg_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
muratugureminoglu marked this conversation as resolved.
Show resolved Hide resolved
stdout, stderr = ffmpeg_process.communicate()

#Function to close the old tab and open new one
def switch_to_first_tab(driver):
driver.close()
driver.switch_to.window(driver.window_handles[0])

webhook_url = "https://hooks.slack.com/services/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"
icon_emoji = ":x:"

options = Options()
options.add_argument('--headless')
options.add_argument("--use-fake-ui-for-media-stream")
options.add_argument("--use-fake-device-for-media-stream")
driver = webdriver.Chrome(options=options)
driver.maximize_window()

driver.get("https://antmedia.io/webrtc-samples/")

#Testing Virtual Background Sample Page
for i in range(2):
try:
driver.execute_script("window.open('https://antmedia.io/webrtc-samples/webrtc-virtual-background/', '_blank');")
driver.switch_to.window(driver.window_handles[1])
time.sleep(20)
driver.switch_to.frame(0)
time.sleep(3)
driver.find_element(By.XPATH,"/html/body/div/div/div[4]/div[3]/img").click()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0% of developers fix this issue

E231: missing whitespace after ','

❗❗ 22 similar findings have been found in this PR

🔎 Expand here to view all instances of this finding
File Path Line Number
Selenium/antmedia-samples.py 96
Selenium/antmedia-samples.py 98
Selenium/antmedia-samples.py 118
Selenium/antmedia-samples.py 120
Selenium/antmedia-samples.py 134
Selenium/antmedia-samples.py 136
Selenium/antmedia-samples.py 138
Selenium/antmedia-samples.py 154
Selenium/antmedia-samples.py 156
Selenium/antmedia-samples.py 158

Showing 10 of 22 findings. Visit the Lift Web Console to see all.


ℹ️ Expand to see all @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.


Help us improve LIFT! (Sonatype LiftBot external survey)

Was this a good recommendation for you? Answering this survey will not impact your Lift settings.

[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

time.sleep(5)
driver.find_element(By.XPATH,"/html/body/div/div/div[7]/button[1]").click()
time.sleep(15)
driver.find_element(By.XPATH,"/html/body/div/div/div[7]/button[2]").click()
time.sleep(3)
print("WebRTC virtual background is successful")
break

except:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0% of developers fix this issue

E722: do not use bare 'except'

❗❗ 9 similar findings have been found in this PR

🔎 Expand here to view all instances of this finding
File Path Line Number
Selenium/antmedia-samples.py 124
Selenium/antmedia-samples.py 142
Selenium/antmedia-samples.py 162
Selenium/antmedia-samples.py 187
Selenium/antmedia-samples.py 204
Selenium/antmedia-samples.py 219
Selenium/antmedia-samples.py 237
Selenium/antmedia-samples.py 255
Selenium/antmedia-samples.py 275

Visit the Lift Web Console to find more details in your report.


ℹ️ Expand to see all @sonatype-lift commands

You can reply with the following commands. For example, reply with @sonatype-lift ignoreall to leave out all findings.

Command Usage
@sonatype-lift ignore Leave out the above finding from this PR
@sonatype-lift ignoreall Leave out all the existing findings from this PR
@sonatype-lift exclude <file|issue|path|tool> Exclude specified file|issue|path|tool from Lift findings by updating your config.toml file

Note: When talking to LiftBot, you need to refresh the page to see its response.
Click here to add LiftBot to another repo.


Help us improve LIFT! (Sonatype LiftBot external survey)

Was this a good recommendation for you? Answering this survey will not impact your Lift settings.

[ 🙁 Not relevant ] - [ 😕 Won't fix ] - [ 😑 Not critical, will fix ] - [ 🙂 Critical, will fix ] - [ 😊 Critical, fixing now ]

if i==1:
muratugureminoglu marked this conversation as resolved.
Show resolved Hide resolved
message = "Virtual background test is failed, check -> https://antmedia.io/webrtc-samples/webrtc-virtual-background/"
send_slack_message(webhook_url, message, icon_emoji)
continue

switch_to_first_tab(driver)

#Testing WebRTC and HLS Comparison Live Demo Page
try:
driver.execute_script("window.open('https://antmedia.io/live-demo/', '_blank');")
driver.switch_to.window(driver.window_handles[1])
time.sleep(15)
driver.find_element(By.XPATH,"/html/body/div/div/article[2]/div[2]/div[1]/div[1]/div/div/p/button[1]").click()
time.sleep(15)
driver.find_element(By.XPATH,"/html/body/div/div/article[2]/div[2]/div[1]/div[1]/div/div/p/button[2]").click()
time.sleep(3)
print("Live demo is successful")

except:
message = "Livedemo test is failed, check -> https://antmedia.io/live-demo/"
send_slack_message(webhook_url, message, icon_emoji)

switch_to_first_tab(driver)

#Testing WebRTC to WebRTC Sample Page
try:
driver.execute_script("window.open('https://antmedia.io/webrtc-samples/webrtc-publish-webrtc-play/', '_blank');")
driver.switch_to.window(driver.window_handles[1])
time.sleep(15)
driver.switch_to.frame(0)
time.sleep(3)
driver.find_element(By.XPATH,"/html/body/div/div/div[8]/button[1]").click()
time.sleep(10)
driver.find_element(By.XPATH,"/html/body/div/div/div[7]/div[1]/a").click()
time.sleep(5)
driver.find_element(By.XPATH,"/html/body/div/div/div[8]/button[2]").click()
time.sleep(3)
print("WebRTC to WebRTC is successful")

except:
message = "WebRTC to WebRTC test is failed, check -> https://antmedia.io/webrtc-samples/webrtc-publish-webrtc-play/"
send_slack_message(webhook_url, message, icon_emoji)

driver.close()
driver.switch_to.window(driver.window_handles[1])
switch_to_first_tab(driver)

#Testing WebRTC to HLS Sample Page
try:
driver.execute_script("window.open('https://antmedia.io/webrtc-samples/webrtc-publish-hls-play/', '_blank');")
driver.switch_to.window(driver.window_handles[1])
time.sleep(15)
driver.switch_to.frame(0)
time.sleep(3)
driver.find_element(By.XPATH,"/html/body/div/div/div[8]/button[1]").click()
time.sleep(10)
driver.find_element(By.XPATH,"/html/body/div/div/div[7]/div[1]/a").click()
time.sleep(5)
driver.find_element(By.XPATH,"/html/body/div/div/div[8]/button[2]").click()
time.sleep(5)
print("WebRTC to HLS is successful")

except:
message = "WebRTC to HLS test is failed, check -> https://antmedia.io/webrtc-samples/webrtc-publish-webrtc-play/"
send_slack_message(webhook_url, message, icon_emoji)

driver.close()
driver.switch_to.window(driver.window_handles[1])
switch_to_first_tab(driver)

#Testing WebRTC audio publish sample page
try:
driver.execute_script("window.open('https://antmedia.io/webrtc-samples/webrtc-audio-publish-play/', '_blank');")
driver.switch_to.window(driver.window_handles[1])
time.sleep(5)
driver.switch_to.frame(0)
time.sleep(2)
driver.find_element(By.XPATH,"/html/body/div/div/div[6]/button[1]").click()
time.sleep(3)
driver.find_element(By.XPATH,"/html/body/div/div/div[5]/div[1]/a").click()
driver.switch_to.window(driver.window_handles[2])
time.sleep(2)
driver.switch_to.frame(0)
time.sleep(2)
driver.find_element(By.XPATH,"/html/body/div/div/div[4]/button[1]").click()
time.sleep(10)
driver.find_element(By.XPATH,"/html/body/div/div/div[4]/button[2]").click()
time.sleep(2)
print("WebRTC audio publish is successful")

except:
message = "WebRTC audio publish and play test is failed, check -> https://antmedia.io/webrtc-samples/webrtc-audio-publish-play/"
send_slack_message(webhook_url, message, icon_emoji)

driver.close()
driver.switch_to.window(driver.window_handles[1])
switch_to_first_tab(driver)

#Testing RTMP to WebRTC sample page
try:
driver.execute_script("window.open('https://antmedia.io/webrtc-samples/rtmp-publish-webrtc-play/', '_blank');")
muratugureminoglu marked this conversation as resolved.
Show resolved Hide resolved
driver.switch_to.window(driver.window_handles[1])
time.sleep(15)
driver.switch_to.frame(0)
time.sleep(5)
rtmp_element = driver.find_element(By.XPATH,"/html/body/div/div/div[3]/div[1]/div")
rtmp_url = rtmp_element.text
output= 'flv'
publish_with_ffmpeg(output, rtmp_url)
print("RTMP to WebRTC is successful")

except:
message = "RTMP to WebRTC test is failed, check -> https://antmedia.io/webrtc-samples/rtmp-publish-wertc-play/"
send_slack_message(webhook_url, message, icon_emoji)

switch_to_first_tab(driver)

#Testing RTMP to HLS sample page
try:
driver.execute_script("window.open('https://antmedia.io/webrtc-samples/rtmp-publish-hls-play/', '_blank');")
driver.switch_to.window(driver.window_handles[1])
time.sleep(15)
driver.switch_to.frame(0)
time.sleep(5)
rtmp_element = driver.find_element(By.XPATH,"/html/body/div/div/div[3]/div[1]/div")
rtmp_url = rtmp_element.text
output= 'flv'
publish_with_ffmpeg(output, rtmp_url)
print("RTMP to HLS is successful")

except:
message = "RTMP to HLS test is failed, check -> https://antmedia.io/webrtc-samples/rtmp-publish-wertc-play/"
send_slack_message(webhook_url, message, icon_emoji)

switch_to_first_tab(driver)

#Testing WebRTC data channel sample page
try:
driver.execute_script("window.open('https://antmedia.io/webrtc-samples/webrtc-data-channel-only/', '_blank');")
driver.switch_to.window(driver.window_handles[1])
time.sleep(15)
driver.switch_to.frame(0)
time.sleep(3)
driver.find_element(By.XPATH,"/html/body/div/div/div[6]/button[1]").click()
time.sleep(5)
text = driver.find_element(By.ID,'dataTextbox')
text.send_keys("Hello, how are you ?")
driver.find_element(By.XPATH,"/html/body/div/div/div[3]/div/div[2]/button").click()
time.sleep(20)
driver.find_element(By.XPATH,"/html/body/div/div/div[6]/button[2]").click()
time.sleep(3)
print("WebRTC data channel is successful")

except:
message = "WebRTC data channel test is failed, check -> https://antmedia.io/webrtc-samples/webrtc-data-channel-only/"
send_slack_message(webhook_url, message, icon_emoji)

driver.quit()