def main(): robot = GRobot(display=True, log_level=logging.DEBUG, develop=False) # Chinese people love proxy. robot.set_proxy('socks5://127.0.0.1:7070') robot.open('https://twitter.com') # Login robot.key_clicks('id=signin-email', USERNAME) robot.key_clicks('id=signin-password', PASSWORD) robot.click("xpath=//td/button[contains(text(),'Sign in')]", expect_loading=True) # Post a twitter robot.key_clicks( "id=tweet-box-mini-home-profile", "GRobot is too powerful.https://github.com/DYFeng/GRobot") # Wait for post success while 1: robot.click( "xpath=//div[@class='module mini-profile']//button[text()='Tweet']" ) try: robot.wait_for_text('Your Tweet was posted') break except: #Something go wrong,refresh page. if 'refresh the page' in robot.content(): robot.reload() # Wait forever. robot.wait_forever()
def main(): # Show the browser window.Open the webkit inspector. robot = GRobot(display=True, develop=False, log_level=logging.DEBUG, loading_timeout=10, operate_timeout=10) # In China,people can only using proxy to access google. robot.set_proxy('socks5://127.0.0.1:7070') #Open google robot.open('http://www.google.com/') #Type out project and search. robot.type('name=q', 'GRobot github') robot.click('name=btnK', expect_loading=True) for i in xrange(1, 10): # Waiting for the ajax page loading. robot.wait_for_xpath("//tr/td[@class='cur' and text()='%s']" % i) if u'https://github.com/DYFeng/GRobot' in robot.content: print 'The porject in page', i break # Click the Next link.We don't use expect_loading.Because it's ajax loading,not page loading. robot.click("xpath=//span[text()='Next']") else: print "Can not found.Make a promotion for it." # Wait forever. robot.wait_forever()
def __init__(self): # Initialise globals self.robot = GRobot("demoAgent", colour="yellow") worldPath = "./../Maps/MazeExtra.map" # this must be the same as that used in RobotGridWorld.pyw (and any other agents operating together) # import world newworld = pickle.load(open(worldPath, 'rb')) self.mapsize = len(newworld) - 2 self.world = [[None] * (self.mapsize + 3) for i in range(self.mapsize + 3)] # World map # take out the buffer walls for i in range(self.mapsize): for j in range(self.mapsize): self.world[i][j] = newworld[i + 1][j + 1] # Erase hazards from memory # TODO: We will need to modify this to remove random rewards as well for i in range(0, self.mapsize): for j in range(0, self.mapsize): if self.world[i][j] == "Hazard": self.world[i][j] = None
def setUp(self): self.robot = GRobot( # display=GRobotGeneralTest.display, develop=GRobotGeneralTest.develop, log_level=GRobotGeneralTest.log_level)