This commit is contained in:
watrabi
2025-09-18 17:55:52 -04:00
commit 977f1ff4b8
15030 changed files with 17324420 additions and 0 deletions
@@ -0,0 +1 @@
__author__ = 'yiwen'
@@ -0,0 +1,36 @@
__author__ = 'yiwen'
import smtplib
from email.mime.text import MIMEText
from email.mime.application import MIMEApplication
from email.mime.multipart import MIMEMultipart
from datetime import date
def send_mail(send_from, send_to, subject, text, attfile=None):
gmail_user = "robloxmobiletest@gmail.com"
gmail_pwd = "hackproof12"
DATE_FORMAT = "%d/%m/%Y"
EMAIL_SPACE = ", "
assert isinstance(send_to, list)
msg = MIMEMultipart()
msg['Subject'] = subject + " %s" % (date.today().strftime(DATE_FORMAT))
msg['To'] = EMAIL_SPACE.join(send_to)
msg['From'] = send_from
msg.attach(MIMEText(text))
if attfile:
part = MIMEApplication(open(attfile,"rb").read())
part.add_header('Content-Disposition', 'attachment', filename=attfile)
msg.attach(part)
try:
server = smtplib.SMTP("smtp.gmail.com", 587)
server.ehlo()
server.starttls()
server.login(gmail_user, gmail_pwd)
print 'login successful'
server.sendmail(send_from, send_to, msg.as_string())
server.close()
print 'successfully sent the mail'
except:
print "failed to send mail"
@@ -0,0 +1,38 @@
__author__ = 'yiwen'
APP_NAME ='/Users/yiwen/Library/Developer/Xcode/DerivedData/RobloxMobile-daaepjbgniaxkmbhdkkduekbtpuy/Build/Products/Release-iphoneos/RobloxTop.app'
#APP_NAME = '/Users/yiwen/Library/Developer/Xcode/DerivedData/RobloxMobile-ahgndzvmjplpvrbhfthvrrniwqkf/Build/Products/Release-iphoneos/RobloxInternal.app'
COMMAND_SERVER ='http://127.0.0.1:4723/wd/hub'
#############ios information###################
PLATFORM = 'iOS'
PLATFORM_VERSION = '7.1'
# APP_VERSION = '2.99.99'
DEVICE_NAME = '8f0a67da884eeea359218fe7818a97530a36c49c'
PD_USERNAME = 'AppleiTunesTestNoBc'
PD_PASSWORD = 'Steve1Jobs1'
#############android information###################
PLATFORM_ANDROID = 'Android'
PLATFORM_ANDROID_VERSION = '4.4'
# APP_VERSION = '2.99.99'
ANDROID_DEVICE_NAME = '8f0a67da884eeea359218fe7818a97530a36c49c'
GT_USERNAME = 'mobiletest'
GT_PASSWORD = 'hackproof12'
MAIN_SERVER = "watrbx.wtf"
GT1_SERVER = 'gametest1.pizzaboxer.fun'
GAMEFORTESTONGT1 = 'Test'
GT2_SERVER = 'gametest2.pizzaboxer.fun'
GAMEFORTESTONGT2 = 'Test'
ST1_SERVER = 'sitetest1.pizzaboxer.fun'
GAMEFORTESTONST1 = "Place"
ST2_SERVER = 'sitetest2.pizzaboxer.fun'
GAMEFORTESTONST2 = "Place"
@@ -0,0 +1,124 @@
__author__ = 'yiwen'
import unittest
import os
from random import randint
from appium import webdriver
from time import sleep
import contants
import commonutils
import time
import subprocess as sp
class IOSTestsBase(unittest.TestCase):
APP_VERSION = '0.0'
DEVICE_NAME = contants.DEVICE_NAME
internal = True
APP_SRC = contants.APP_NAME
DEVICE_TYPE = 'tablet'
TESTER = ''
def setUp(self):
# set up appium
sleep(2)
# sp.call('ios-deploy -i '+ self.DEVICE_NAME+' -b '+self.APP_SRC + ' -r', shell=True)
# sleep(2)
self.driver = webdriver.Remote(
command_executor=contants.COMMAND_SERVER,
desired_capabilities={
'app': self.APP_SRC,
'platformName': contants.PLATFORM,
'platformVersion': contants.PLATFORM_VERSION,
'deviceName': self.DEVICE_NAME,
'autoAcceptAlerts': True,
})
sleep(2)
def tearDown(self):
self.driver.quit()
def selectwheel(self,value):
if self.internal:
if self.DEVICE_TYPE == 'phone':
value = value.replace('www','m')
sleep(3)
wheel = self.driver.find_elements_by_class_name('UIAPickerWheel')
wheel[0].send_keys(value)
def login(self,username,password):
buttons = self.driver.find_elements_by_class_name('UIAButton')
for button in buttons:
if button.get_attribute('name') == 'Login':
button.click()
# clear username first
self.driver.find_elements_by_class_name('UIATextField')[0].clear()
self.driver.find_elements_by_class_name('UIATextField')[0].send_keys(username)
self.driver.find_elements_by_class_name('UIASecureTextField')[0].send_keys(password)
if self.DEVICE_TYPE == 'phone':
buttons = self.driver.find_elements_by_class_name('UIAButton')
for button in buttons:
if button.get_attribute('name') == 'Log in':
button.click()
else:
self.driver.find_elements_by_accessibility_id('Log in')[0].click()
time.sleep(3)
def emailscreenshot(self,full_filename,send_to,testtitle):
self.driver.save_screenshot(full_filename)
time.sleep(3)
commonutils.send_mail(send_from='ywen@watrbx.wtf',send_to=send_to,subject=testtitle+' result',text='automation test screen shot for '+testtitle,attfile=full_filename)
def verifyWebViewStaticText(self,textToVerify,source='webriver'):
if source == 'ios':
# statictext = self.driver.find_elements_by_ios_uiautomation(".scrollViews()[0].webViews()[0].staticTexts()['"+textToVerify+"']")
statictext = self.driver.find_elements_by_xpath('//UIAApplication[1]/UIAWindow[1]/UIAScrollView[1]/UIAWebView[1]/UIAStaticText')
else:
statictext = self.driver.find_elements_by_class_name('UIAStaticText')
for text in statictext:
if text.get_attribute('name') == textToVerify:
return True
return False
def verifyCookieConstrains(self,keys='rewards'):
temp = []
if self.verifyWebViewStaticText(textToVerify='The site is currently offline for maintenance and upgrades.'):
self.driver.find_elements_by_class_name('UIASecureTextField')[0].send_keys(keys)
buttons = self.driver.find_elements_by_class_name('UIAButton')
for button in buttons:
if button.get_attribute('name') == 'O':
temp.append(button)
temp[1].click()
time.sleep(10)
def verifyKeyboard(self):
return self.driver.execute_script('target.frontMostApp().keyboard().isValid()')
def verifyWebLink(self,linktext,source='webriver'):
if source == 'ios':
# statictext = self.driver.find_elements_by_ios_uiautomation(".scrollViews()[0].webViews()[0].staticTexts()['"+textToVerify+"']")
links = self.driver.find_elements_by_xpath('//UIAApplication[1]/UIAWindow[1]/UIAScrollView[1]/UIAWebView[1]/UIAStaticText')
else:
links = self.driver.find_elements_by_class_name('UIALink')
for link in links:
if link.get_attribute('name') == linktext:
return link
return None
def launch_game(self):
playlink = self.verifyWebLink(linktext='Play')
# self.assertTrue(playlink is None,'Did not found Play link on Test Place #1 ')
if playlink:
playlink.click()
# wait till game gets loaded
sleep(10)
# self.driver.execute_script('target.frontMostApp().mainWindow().images()[0].images()[0].tapWithOptions({tapOffset:{x:0.09, y:0.03}});')
# self.assertTrue(self.verifyKeyboard() == True ,'keyboard did not launch , game was not launched')
return
assert False ,"can't found the Play link on page"
@@ -0,0 +1,284 @@
__author__ = 'yiwen'
"""
Simple iOS tests, showing accessing elements and getting/setting text from them.
"""
import unittest
import os
from random import randint
from appium import webdriver
from time import sleep
from automationutils import contants
from automationutils import iostestbase
import time
class IosTestsRoma(iostestbase.IOSTestsBase):
USERNAME = 'mobiletest'
PASSWORD = 'hackproof12'
SERVER = 'http://www.gametest1.pizzaboxer.fun/'
TEST_GAME = 'Test Place #1'
ADS_PLACE = 'Mobile Ad Test'
LAUNCHGAME_TIMEOUT_= 10
# APP test server
APPSERVER = 'http://www.sitetest1.pizzaboxer.fun/'
TIMEOUT = 8
def test001_login(self):
"""
ROBLOX APP LOGIN TEST
Steps:
1.Verify the version on the screen
2.Login in.
"""
print "running test on version "+self.APP_VERSION
self.assertTrue(self.verifyWebViewStaticText(textToVerify=self.APP_VERSION),'the version is not as expected')
self.selectwheel(self.SERVER)
self.login(username=self.USERNAME,password=self.PASSWORD)
time.sleep(5)
self.assertTrue(len(self.driver.find_elements_by_accessibility_id('Login'))==0,'login failed')
def test002_catalog(self):
"""
ROBLOX APP CATALOG TEST
Steps:
1.Login in.
2.Click Nav Bar Button 'CATALOG'.
3.Verify the Page by checking text 'Featured Items on ROBLOX'
"""
self.selectwheel(self.APPSERVER)
self.login(username=self.USERNAME,password=self.PASSWORD)
if self.DEVICE_TYPE == 'phone':
self.driver.find_elements_by_accessibility_id('MORE')[0].click()
time.sleep(3)
#Inventory page will be the 3rd UIAButton in the grid
self.driver.find_elements_by_class_name('UIAButton')[1].click()
else:
self.driver.find_elements_by_accessibility_id('CATALOG')[0].click()
time.sleep(8)
self.verifyCookieConstrains()
time.sleep(8)
if self.DEVICE_TYPE == 'phone':
self.assertTrue(self.verifyWebViewStaticText(textToVerify='All Categories'),'after click catalog bar the page did not going forward')
else:
self.assertTrue(self.verifyWebViewStaticText(textToVerify='Featured Items on ROBLOX'),'after click catalog bar the page did not going forward')
def test003_inventory(self):
"""
ROBLOX APP INVENTORY TEST
Steps:
1.Login in.
2.Click Nav Bar Button 'INVENTORY'.
3.Verify the Page by checking text 'Character Customizer'
"""
self.selectwheel(self.APPSERVER)
self.login(username=self.USERNAME,password=self.PASSWORD)
self.driver.find_elements_by_accessibility_id('MORE')[0].click()
time.sleep(3)
if self.DEVICE_TYPE == 'phone':
#Inventory page will be the 4rd UIAButton in the grid
self.driver.find_elements_by_class_name('UIAButton')[4].click()
else:
#Inventory page will be the 3rd UIAButton in the grid
self.driver.find_elements_by_class_name('UIAButton')[3].click()
time.sleep(8)
self.verifyCookieConstrains()
time.sleep(8)
self.assertTrue(self.verifyWebViewStaticText(textToVerify='My Inventory'),'after click inventory bar the page did not going forward')
def test004_profile(self):
"""
ROBLOX APP PROFILE TEST
Steps:
1.Login in.
2.Click Nav Bar Button 'PROFILE'.
3.Verify the Page by checking login username is on the screen
"""
self.selectwheel(self.APPSERVER)
self.login(username=self.USERNAME,password=self.PASSWORD)
self.driver.find_elements_by_accessibility_id('MORE')[0].click()
time.sleep(3)
if self.DEVICE_TYPE == 'phone':
#Profile page will be the 1st UIAButton in the grid
self.driver.find_elements_by_class_name('UIAButton')[2].click()
else:
#Profile page will be the 1st UIAButton in the grid
self.driver.find_elements_by_class_name('UIAButton')[1].click()
time.sleep(8)
self.verifyCookieConstrains()
time.sleep(8)
self.assertTrue(self.verifyWebViewStaticText(textToVerify=self.USERNAME),'after click profile bar the page did not going forward')
def test005_messages(self):
"""
ROBLOX APP MESSAGES TEST
Steps:
1.Login in.
2.Click Nav Bar Button 'MESSAGES'.
3.Verify the Page by checking text 'Inbox'
"""
self.selectwheel(self.APPSERVER)
self.login(username=self.USERNAME,password=self.PASSWORD)
self.driver.find_elements_by_accessibility_id('MESSAGES')[0].click()
time.sleep(8)
self.verifyCookieConstrains()
time.sleep(8)
if self.DEVICE_TYPE == 'phone':
self.assertTrue(self.verifyWebViewStaticText(textToVerify='Sent by'),'after click profile bar the page did not going forward')
else:
self.assertTrue(self.verifyWebViewStaticText(textToVerify='Inbox'),'after click profile bar the page did not going forward')
def test006_group(self):
"""
ROBLOX APP GROUP TEST
Steps:
1.Login in.
2.Click Nav Bar Button 'MESSAGES'.
3.Verify the Page by checking text 'Inbox'
"""
self.selectwheel(self.APPSERVER)
self.login(username=self.USERNAME,password=self.PASSWORD)
self.driver.find_elements_by_accessibility_id('MORE')[0].click()
time.sleep(3)
#Group page will be the 5th UIAButton in the grid
self.driver.find_elements_by_class_name('UIAButton')[5].click()
time.sleep(8)
self.verifyCookieConstrains()
time.sleep(10)
# can't find statictext
if self.DEVICE_TYPE == 'phone':
self.assertTrue(self.verifyWebViewStaticText(textToVerify='Search for groups'),'after click group bar the page did not going forward')
else:
self.assertTrue(self.verifyWebViewStaticText(textToVerify='Create a Group'),'after click group bar the page did not going forward')
def test007_game_launch(self):
"""
ROBLOX APP GAME LAUNCH TEST
Steps:
1.Login in.
2.in game page, click any game and join
3.click chat button. check keyboard to verify the game is succefully launched.
"""
self.selectwheel(self.SERVER)
self.login(username=self.USERNAME,password=self.PASSWORD)
time.sleep(2)
self.driver.find_elements_by_accessibility_id('GAMES')[0].click()
#self.verifyCookieConstrains()
# else:
# # self.driver.find_elements_by_accessibility_id('MORE')[0].click()
# # time.sleep(3)
# # #Profile page will be the 1st UIAButton in the grid
# # self.driver.find_elements_by_class_name('UIAButton')[1].click()
# # self.verifyCookieConstrains()
time.sleep(8)
if self.DEVICE_TYPE is 'phone':
self.driver.execute_script('target.frontMostApp().mainWindow().scrollViews()[0].webViews()[0].links()[4].tap();')
time.sleep(5)
self.driver.execute_script('target.frontMostApp().mainWindow().scrollViews()[0].webViews()[0].links()["'+self.TEST_GAME+'"].scrollToVisible();')
self.driver.execute_script('target.frontMostApp().mainWindow().scrollViews()[0].webViews()[0].links()["'+self.TEST_GAME+'"].tap();')
time.sleep(20)
self.emailscreenshot('screenshot.jpg',send_to=[self.TESTER],testtitle='game_launch')
return
assert False, 'cannot find the game '+self.TEST_GAME
else:
statictext = self.driver.find_elements_by_class_name('UIACollectionCell')
for text in statictext:
if self.TEST_GAME in text.get_attribute('name'):
print 'game found.'
text.click()
time.sleep(3)
self.launch_game()
time.sleep(20)
self.emailscreenshot('screenshot.jpg',send_to=[self.TESTER],testtitle='game_launch')
return
assert False, 'cannot find the game '+self.TEST_GAME
def test008_ingame_ads(self):
"""
ROBLOX APP GAME LAUNCH TEST
Steps:
1.Login in.
2.in game page, click 'Mobile Ad Tests' game and join
3.for a certain time. take screenshot and sent to verifer
"""
self.selectwheel(self.SERVER)
self.login(username=self.USERNAME,password=self.PASSWORD)
time.sleep(2)
self.driver.find_elements_by_accessibility_id('GAMES')[0].click()
#self.verifyCookieConstrains()
time.sleep(8)
if self.DEVICE_TYPE is 'phone':
self.driver.execute_script('target.frontMostApp().mainWindow().scrollViews()[0].webViews()[0].links()[4].tap();')
time.sleep(5)
self.driver.execute_script('target.frontMostApp().mainWindow().scrollViews()[0].webViews()[0].links()["'+self.ADS_PLACE+'"].scrollToVisible();')
self.driver.execute_script('target.frontMostApp().mainWindow().scrollViews()[0].webViews()[0].links()["'+self.ADS_PLACE+'"].tap();')
time.sleep(20)
self.emailscreenshot('screenshot.jpg',send_to=[self.TESTER],testtitle='ingame_ads')
return
assert False, 'cannot find the game '+self.ADS_PLACE
else:
time.sleep(5)
statictext2 = self.driver.find_elements_by_class_name('UIACollectionCell')
for text in statictext2:
if self.ADS_PLACE in text.get_attribute('name'):
print 'ads play found.'
text.click()
time.sleep(3)
playlink = self.verifyWebLink(linktext='Play')
if playlink:
playlink.click()
time.sleep(20)
self.emailscreenshot('screenshot.jpg',send_to=[self.TESTER],testtitle='ingame_ads')
return
assert False, 'cannot find the game '+self.ADS_PLACE
def test009_game_launch_st1(self):
"""
ROBLOX APP GAME LAUNCH TEST on SiteTest1
Steps:
1.Login in.
2.in game page, click any game and join
3.click chat button. check keyboard to verify the game is succefully launched.
"""
self.selectwheel(self.APPSERVER)
self.login(username=self.USERNAME,password=self.PASSWORD)
time.sleep(2)
self.driver.find_elements_by_accessibility_id('GAMES')[0].click()
self.verifyCookieConstrains()
# else:
# # self.driver.find_elements_by_accessibility_id('MORE')[0].click()
# # time.sleep(3)
# # #Profile page will be the 1st UIAButton in the grid
# # self.driver.find_elements_by_class_name('UIAButton')[1].click()
# # self.verifyCookieConstrains()
time.sleep(8)
if self.DEVICE_TYPE is 'phone':
self.driver.execute_script('target.frontMostApp().mainWindow().scrollViews()[0].webViews()[0].links()[4].tap();')
time.sleep(5)
self.driver.execute_script('target.frontMostApp().mainWindow().scrollViews()[0].webViews()[0].links()["'+self.TEST_GAME+'"].scrollToVisible();')
self.driver.execute_script('target.frontMostApp().mainWindow().scrollViews()[0].webViews()[0].links()["'+self.TEST_GAME+'"].tap();')
time.sleep(20)
self.emailscreenshot('screenshot.jpg',send_to=[self.TESTER],testtitle='game_launch')
return
assert False, 'cannot find the game '+self.TEST_GAME
else:
statictext = self.driver.find_elements_by_class_name('UIACollectionCell')
for text in statictext:
if 'Place' in text.get_attribute('name'):
print 'game found.'
text.click()
time.sleep(3)
self.launch_game()
time.sleep(20)
self.emailscreenshot('screenshot.jpg',send_to=[self.TESTER],testtitle='game_launch for sitetest1')
return
assert False, 'cannot find the game '+self.TEST_GAME
@@ -0,0 +1,118 @@
__author__ = 'yiwen'
import unittest
from automationutils import contants
import ios_roma
from subprocess import Popen, PIPE, STDOUT
import argparse
import time
from teamcity import is_running_under_teamcity
from teamcity.unittestpy import TeamcityTestRunner
class TestRunner(unittest.TestCase):
test = None
androidtest = None
parser = argparse.ArgumentParser(description='All arguments needed for running a test')
parser.add_argument('-t',dest='device_type',action='store',help='target device type: currently surrpoot phone & tablet')
parser.add_argument('-p', dest='platform',action='store', help='target platfom : currently surppot ios and android')
parser.add_argument('-id',dest='device_id', action='store', help="target device id : for ios, use 'instruments -w device', for android, use 'adb devices'")
parser.add_argument('-v',dest='app_version', action='store', help='app version')
parser.add_argument('-in',dest='internal_version', action='store', help='internal_version_onoff')
parser.add_argument('-s',dest='target_server',action='store',help='target test server: 1.production ,2.test1, 3.test2, 4.stest1, 5.stest2')
parser.add_argument('-src',dest='appsrc',action='store',help='src for target app')
parser.add_argument('-tester',dest='tester',action='store',help='tester email')
args = parser.parse_args()
TESTER = args.tester
if args.device_type == 'phone':
prefix = 'm.'
DEVICE_TYPE = 'phone'
else:
prefix = 'www.'
DEVICE_TYPE = 'tablet'
if 'test' in args.target_server:
USERNAME = contants.GT_USERNAME
PASSWORD = contants.GT_PASSWORD
if args.target_server == 'test1':
SERVER = 'http://'+prefix+contants.GT1_SERVER+'/'
TEST_GAME = contants.GAMEFORTESTONGT1
elif args.target_server == 'test2':
SERVER = 'http://'+prefix+contants.GT2_SERVER+'/'
TEST_GAME = contants.GAMEFORTESTONGT2
elif args.target_server == 'stest1':
SERVER = 'http://'+prefix+contants.ST1_SERVER+'/'
TEST_GAME = contants.GAMEFORTESTONST1
elif args.target_server == 'stest2':
SERVER = 'http://'+prefix+contants.ST2_SERVER+'/'
TEST_GAME = contants.GAMEFORTESTONST2
else:
USERNAME = contants.PD_USERNAME
PASSWORD = contants.PD_PASSWORD
TEST_GAME = contants.PD_USERNAME+"'s Place"
SERVER = 'http://'+prefix+contants.MAIN_SERVER+'/'
if args.platform == 'ios':
iostest = ios_roma.IosTestsRoma
iostest.APP_SRC = args.appsrc
if args.internal_version == 'false':
iostest.internal = False
else:
iostest.internal = True
iostest.DEVICE_NAME = args.device_id
iostest.APP_VERSION = args.app_version
iostest.USERNAME = USERNAME
iostest.PASSWORD = PASSWORD
iostest.TEST_GAME = TEST_GAME
iostest.SERVER = SERVER
iostest.DEVICE_TYPE= DEVICE_TYPE
iostest.TESTER = TESTER
elif args.platform == 'android':
androidtest = android_roma.AndroidTestsRoma
androidtest.APP_SRC = args.appsrc
if args.internal_version == 'false':
androidtest.internal = False
else:
androidtest.internal = True
androidtest.DEVICE_NAME = args.device_id
androidtest.APP_VERSION = args.app_version
androidtest.USERNAME = USERNAME
androidtest.PASSWORD = PASSWORD
androidtest.TEST_GAME = TEST_GAME
androidtest.SERVER = SERVER[7:]
if __name__ == '__main__':
if not TestRunner.iostest and not TestRunner.androidtest:
print 'lack of arguments, cancel test. plese read -h before run the test'
elif TestRunner.iostest:
print TestRunner.args.device_id
appiumprocess = Popen(['appium', '-U',TestRunner.args.device_id])
suite = unittest.TestLoader().loadTestsFromTestCase(TestRunner.iostest)
# suite = unittest.TestLoader().loadTestsFromName(name='test_gamelaunch',module=TestRunner.iostest)
print 'Smoke Test '+'iOS'+' '+TestRunner.args.platform+' v '+TestRunner.iostest.APP_VERSION+' On '+TestRunner.iostest.SERVER
# fp = file('report'+contants.PLATFORM+'.html', 'wb')
# runner = HTMLTestRunner.HTMLTestRunner(
# stream=fp,
# title='Smoke Test '+'iOS'+' '+contants.PLATFORM_VERSION+' v '+TestRunner.iostest.APP_VERSION + ' On ' +TestRunner.iostest.SERVER,
# description='smoke test for '+TestRunner.iostest.APP_VERSION
# )
# run the test
runner = TeamcityTestRunner()
runner.run(suite)
appiumprocess.terminate()
elif TestRunner.androidtest:
print TestRunner.args.device_id
appiumprocess = Popen(['appium', '-U',TestRunner.args.device_id])
suite = unittest.TestLoader().loadTestsFromTestCase(TestRunner.iostest)
# suite = unittest.TestLoader().loadTestsFromName(name='test_gamelaunch',module=TestRunner.iostest)
print 'Smoke Test '+'Android'+' '+TestRunner.args.platform+' v '+TestRunner.androidtest.APP_VERSION+' On '+TestRunner.androidtest.SERVER
appiumprocess.terminate()
@@ -0,0 +1,13 @@
import argparse
if __name__ == '__main__':
parser = argparse.ArgumentParser(description="some information here")
args = parser.parse_args()