Best Python code snippet using pom_python
91question_bk2.py
Source:91question_bk2.py  
...18	driver.maximize_window()19	while True:	20		driver.get(url)21		sleep(1)22		if driver.find_elements(By.CLASS_NAME,"ant-radio-input"):23			return driver24			break2526#翻页ãä¸æãæ¥é27def next_page(driver):28	if driver.find_element(By.CLASS_NAME,"survey-title").text == "ç»æé¡µ" and driver.find_elements(By.XPATH,"//*[contains(text(),'éæ¾')]"):29		driver.quit()30		return 131	elif driver.find_element(By.CLASS_NAME,"survey-title").text == "ç»æé¡µ":32		driver.quit()33		return 234	elif driver.find_elements(By.CSS_SELECTOR,"a[role=\"button\"]"):35		print("翻页ãä¸æãæ¥é")36		nextpage=driver.find_element(By.CSS_SELECTOR,"a[role=\"button\"]")37#		nextpage.click()38#		driver.switch_to.window(driver.window_handles[0])39#		return 040		try:41			nextpage.click()42		except:43			sleep(1)44			nextpage.click()45			driver.switch_to.window(driver.window_handles[0])46			return 047		else:48			driver.switch_to.window(driver.window_handles[0])49			return 050	else:51		return 35253#åé54def single_radio(diver):55	#if driver.find_elements(By.ID,"1468879590070353922") or driver.find_elements(By.ID,"1466615958692044801") or driver.find_elements(By.ID,"1468427864989114369") or driver.find_elements(By.ID,"1468429089340006402"):  56	if driver.find_elements(By.CLASS_NAME,"age") or driver.find_elements(By.CLASS_NAME,"base-radio"):57	#S1-A1-A12-A1358		print("åé")59		radios1 = driver.find_elements(By.CLASS_NAME,"ant-radio-input")60		radios2 = driver.find_elements(By.CSS_SELECTOR,("input[disabled]"))61		radios = list(set(radios1)-set(radios2))62		radio = random.choice(radios)63		radio.click()646566def list_boxs(driver):67	if driver.find_elements(By.CLASS_NAME,"age") or driver.find_elements(By.CLASS_NAME,"city"): #S1-S268		boxs = driver.find_elements(By.CLASS_NAME,"ant-select-selector")69		for box in boxs:70			if box.is_displayed():71				pass72			else:73				boxs.remove(box)74		num = len(boxs)75		for i in range(num):76			box = boxs[i].find_element(By.CLASS_NAME,"ant-select-selection-search-input")77			box.click()78			box_list = driver.find_elements(By.CLASS_NAME,"ant-select-dropdown")[-1]79			if len(box_list.find_element(By.CLASS_NAME,"rc-virtual-list-holder-inner").find_elements(By.CLASS_NAME,"ant-select-item-option-content")) > 8: 80				m = random.randrange(20)81				for i in range(m):82					drag = box_list.find_element(By.CLASS_NAME,"rc-virtual-list-scrollbar").find_element(By.CLASS_NAME,"rc-virtual-list-scrollbar-thumb")83					ActionChains(driver).drag_and_drop_by_offset(drag,0,10).perform()84				options = box_list.find_element(By.CLASS_NAME,"rc-virtual-list-holder-inner").find_elements(By.CLASS_NAME,"ant-select-item-option-content")85				option = random.choice(options[1:-2])86				option.click()87			else:				88				options = box_list.find_element(By.CLASS_NAME,"rc-virtual-list-holder-inner").find_elements(By.CLASS_NAME,"ant-select-item-option-content")89				option = random.choice(options)90				option.click()919293#䏿åé94def dropdown_radio(driver):95	#if driver.find_elements(By.ID,"1466616122777411586"):   96	if driver.find_elements(By.CLASS_NAME,"dropdown-radio"):97	#A298		print("䏿åé")99		options = Select(driver.find_element(By.TAG_NAME,"select"))100		number = random.randint(1,len(options.options)-1)101		options.select_by_index(number)	102103	104'''105def matrix_radio(driver):106	#ç©éµåéï¼å«ç¦ç¨ï¼107	#if	driver.find_elements(By.ID,"1466616582926114818") or driver.find_elements(By.ID,"1466639248965160964") or driver.find_elements(By.ID,"1466639248977743895"):108	if  driver.find_elements(By.CLASS_NAME,"matrix_wrapper__2c6Kh") and driver.find_elements(By.CLASS_NAME,"matrix_openContainer__1xqzZ"): #A31-A32-A36109		try:110			print("ç©éµåé")111			radios1 = driver.find_elements(By.CLASS_NAME,"ant-radio-input")112			radios1_disable = driver.find_elements(By.CSS_SELECTOR,("input[disabled]"))113			row = len(driver.find_elements(By.TAG_NAME,"li"))-1114			column = int(len(radios1)/row)115			list1 = numpy.array(radios1).reshape(row,column)116			if radios1_disable:117				for i in range(row):118					list2=[]119					for j in range(column):120						for radio_disable in radios1_disable:121							if list1[i][j] != radio_disable:122								list2.append(list1[i][j])123					radio = random.choice(list2)124					radio.click()125			else:126				for i in range(row):127					radio = random.choice(list1[i])128					radio.click()129		except:130			pass131	elif driver.find_elements(By.ID,"1466642621613395969") or driver.find_elements(By.ID,"1469128974213251073") or driver.find_elements(By.ID,"1469131169214169089"):132		print("ç©éµåéï¼ä¸ä¸å·¦å³å¯ä¸ï¼")133		radios = driver.find_elements(By.CLASS_NAME,"matrix_openContainer__1xqzZ")134		row_all = len(driver.find_elements(By.TAG_NAME,"li"))135		row_disable = len(driver.find_elements(By.CLASS_NAME,"matrix_titleRow__3Ab16"))136		row = int(row_all - row_disable)137		column = int(len(radios)/row)138		list1 = numpy.array(radios).reshape(row,column)139		for i in range(row):140			for j in range(column):141				if list1[i][j].get_attribute('innerHTML'):142					pass143				else:144					list1[i][j] = False145		list2 = list(range(column))146		if row > column:147			rows = random.sample(range(row),column)148		else:149			rows = range(row)150		for i in rows:	151			for j in list2:152				list3=list2153				if list1[i][j]:154					pass155				else:156					list3.remove(j)157			k = random.choice(list3)158			list1[i][k].click()159			list2.remove(k)160'''161162def matrix_radio(driver):163	#ç©éµåéï¼å«ç¦ç¨ï¼ä¸ä¸å·¦å³å¯ä¸ï¼164	if  driver.find_elements(By.CLASS_NAME,"matrix_wrapper__2c6Kh") and driver.find_elements(By.CLASS_NAME,"matrix_openContainer__1xqzZ"): #A31-A32-A36-A37-A38-A56a-A56b165		print("ç©éµåé(嫿¸æ¾)")166		old_row = "None"167		while True:168			rows = driver.find_elements(By.TAG_NAME,"li")169			row = rows[-1]170			if row == old_row:171				break172			else:173				while True:174					option = random.choice(row.find_elements(By.CLASS_NAME,"ant-radio-input"))175					if option.is_enabled:176						option.click()177						break178				old_row = row 179		row_all = len(driver.find_elements(By.TAG_NAME,"li"))180		row_disable = len(driver.find_elements(By.CLASS_NAME,"matrix_titleRow__3Ab16"))181		radios = driver.find_elements(By.CLASS_NAME,"ant-radio-input")182		ges = driver.find_elements(By.CLASS_NAME,"matrix_openContainer__1xqzZ")183		radios_disable = driver.find_elements(By.CSS_SELECTOR,("input[disabled]"))184		row = int(row_all - row_disable)185		column = int(len(ges)/row)186		if len(radios) == len(ges):187			list1 = numpy.array(radios).reshape(row,column)188		else:189			list1 = numpy.array(ges).reshape(row,column)190			for i in range(row):191				for j in range(column):192					if list1[i][j].find_elements(By.CLASS_NAME,"ant-radio-input"):193						list1[i][j] = list1[i][j].find_element(By.CLASS_NAME,"ant-radio-input")194					else:195						list1[i][j] = False196		while True:197			row_index = random.randrange(row-1)198			column_index = random.randrange(column)199			if (list1[row_index][column_index] not in radios_disable) and (list1[row_index+1][column_index] not in radios_disable) and (list1[row_index][column_index] != False) and (list1[row_index+1][column_index] != False):200				list1[row_index][column_index].click()201				list1[row_index+1][column_index].click()202				break203		sleep(1)204		if (list1[row_index][column_index].is_selected()) and (list1[row_index+1][column_index].is_selected()) and not (driver.find_elements(By.XPATH,"//*[contains(text(),'æéè¦')]")):205			if radios_disable:206				for i in range(row):207					list2=[]208					for j in range(column):209						for radio_disable in radios_disable:210							if list1[i][j] != radio_disable:211								list2.append(list1[i][j])212					radio = random.choice(list2)213					radio.click()214			else:215				for i in range(row):216					radio = random.choice(list1[i])217					radio.click()218219		elif (driver.find_elements(By.XPATH,"//*[contains(text(),'æéè¦')]")) and (driver.find_elements(By.XPATH,"//*[contains(text(),'以ä¸åæ ')]")):220			list2 = list(range(column))221			if row > column:222				rows = random.sample(range(row),column)223			else:224				rows = range(row)225			old_j =0226			for i in rows:227				while True:228					j = random.choice(list2)229					if ((old_j < j) or ((old_j ==j) and (j == list2[-1])))  and (list1[i][j]):230						list1[i][j].click()231						old_j=j 232						break	233		else:234			list2 = list(range(column))235			if row > column:236				rows = random.sample(range(row),column)237			else:238				rows = range(row)239			try:240				for i in rows:	241					for j in list2:242						list3=list2243						if list1[i][j]:244							pass245						else:246							list3.remove(j)247					k = random.choice(list3)248					list1[i][k].click()249					list2.remove(k)250			except:251				pass252253254	255256257def ant_input(driver):258	#è¾å
¥ææ¬259	#if driver.find_elements(By.ID,"1466639249007104011"):260	if driver.find_elements(By.CLASS_NAME,"questionContent_wrapper__1CciB") and driver.find_elements(By.CLASS_NAME,"ant-input") and driver.find_elements(By.CLASS_NAME,"matrix_wrapper__2c6Kh") and driver.find_elements(By.XPATH,"//*[contains(text(),'请填å')]") and driver.find_elements(By.CLASS_NAME,"matrix_titleRow__3Ab16"):261		print("test1")262		rows_all = driver.find_elements(By.TAG_NAME,"li")263		rows_disable =  driver.find_elements(By.CLASS_NAME,"matrix_titleRow__3Ab16")264		rows = list(set(rows_all) -set(rows_disable))265		columns = rows_disable[-1].find_elements(By.XPATH,"//*[contains(text(),'请填å')]")266		options = driver.find_elements(By.CLASS_NAME,"ant-input")267		if len(options) == int(len(rows)*len(columns)):268			list1= numpy.array(options).reshape(len(rows),len(columns))269		for i in range(len(columns)):270			if columns[i].text == "请填å2ï¼æ°å1~10ï¼":271				index_10 = i 272			elif columns[i].text == "请填å3ï¼æ´æ°1~100ï¼":273				index_100 = i 274		for i in range(len(rows)):275			for j in range(len(columns)):276				if list1[i][j].get_attribute('value'):277					pass278				elif j == index_10:279					list1[i][j].send_keys(random.randint(1,10))280				elif j == index_100:281					list1[i][j].send_keys(random.randint(1,100))282				else:283					list1[i][j].send_keys("Bruce test!")284	elif driver.find_elements(By.CLASS_NAME,"base-input") and driver.find_elements(By.CLASS_NAME,"option-text") and driver.find_elements(By.CLASS_NAME,"q-content-option") and driver.find_elements(By.CLASS_NAME,"ant-input.option-input"):285		options = driver.find_elements(By.CLASS_NAME,"q-content-option")286		print("test2")287		for option in options:288			if option.find_element(By.CLASS_NAME,"ant-input.option-input").get_attribute('value'):289	 			pass290			elif option.find_element(By.CLASS_NAME,"option-text").text == "请填å2ï¼æ°å1~10ï¼":291				option.find_element(By.CLASS_NAME,"ant-input.option-input").send_keys(random.randint(1,10))292			elif option.find_element(By.CLASS_NAME,"option-text").text == "请填å3ï¼æ´æ°1~100ï¼":293				option.find_element(By.CLASS_NAME,"ant-input.option-input").send_keys(random.randint(1,100))294			else:295				option.find_element(By.CLASS_NAME,"ant-input.option-input").send_keys("Bruce test!")296	elif driver.find_elements(By.CLASS_NAME,"ant-input"):297		for i in driver.find_elements(By.CLASS_NAME,"ant-input"):298			i.send_keys("Bruce test!")299300	# 	for i in [1,2,3,4]:301	# 		break302	# 		ele =  driver.find_element(By.XPATH,f"/html/body/div/div/div[2]/div/div/div[1]/div/div[2]/div/div/div/div[{i}]/section/div/input")303	# 		if ele.get_attribute('value'):304	# 			pass305	# 		else:306	# 			if i == 2:307	# 				ele.send_keys(random.randint(1,10))308	# 			elif i == 3:309	# 				ele.send_keys(random.randint(1,100))310	# 			else:311	# 				ele.send_keys("Bruce test!")312	# elif driver.find_elements(By.ID,"1469209486710415361"):313	# 	for i in [2,3]:314	# 		break315	# 		for j in [2,3,4,5]:316	# 			ele = driver.find_element(By.XPATH,f"/html/body/div/div/div[2]/div/div/div[1]/div/div[2]/ul/li[{i}]/div[{j}]/div/input")317	# 			if ele.get_attribute('value'):318	# 				pass319	# 			else:320	# 				if (i == 2 and j == 3) or (i ==3 and j == 3):321	# 					ele.send_keys(random.randint(1,10))322	# 				elif (i == 2 and j == 4) or (i ==3 and j == 4):	323	# 					ele.send_keys(random.randint(1,100))324	# 				else:325	# 					ele.send_keys("Bruce test!")326327328329330331332def radio_page(driver):333#å¤é¡µåéï¼å«ç¦ç¨ï¼334	#if driver.find_elements(By.ID,"1466639248969355294") or driver.find_elements(By.ID,"1468882776676040706"):335	radios = list(driver.find_elements(By.CLASS_NAME,"ant-radio-input"))336	print(r"å¤é¡µåéï¼å«ç¦ç¨ï¼")337	radios_disable = driver.find_elements(By.CSS_SELECTOR,("input[disabled]"))338	row = len(driver.find_elements(By.CSS_SELECTOR,("div[data-index]")))339	column = int(len(radios)/row)340	list1 = numpy.array(radios).reshape(row,column)341	if radios_disable:342		for i in range(row):343			list2=[]344			for j in range(column):345				for radio_disable in radios_disable:346					if list1[i][j] != radio_disable:347						list2.append(list1[i][j])348			radio = random.choice(list2)349			radio.click()350			if driver.find_elements(By.CLASS_NAME,"ant-radio.ant-radio-checked") and driver.find_elements(By.CLASS_NAME,"anticon.anticon-right"):351				driver.find_element(By.CLASS_NAME,"anticon.anticon-right").click()352			driver.forward()353			driver.switch_to.window(driver.window_handles[0])354			sleep(1)			355	else:356		for i in range(row):357			radio = random.choice(list1[i])358			radio.click()359			if driver.find_elements(By.CLASS_NAME,"ant-radio.ant-radio-checked") and driver.find_elements(By.CLASS_NAME,"anticon.anticon-right"):360				driver.find_element(By.CLASS_NAME,"anticon.anticon-right").click()361			driver.forward()362			driver.switch_to.window(driver.window_handles[0])363			sleep(1)364365366def maxdiff_row(driver):367#å·¦å³åé368	#if driver.find_elements(By.ID,"1466639248969355272"):369	if driver.find_elements(By.CLASS_NAME,"maxdiff-row"):370	#A33371		print("å·¦å³åé")372		radios = list(driver.find_elements(By.CLASS_NAME,"ant-radio-input"))373		row=int(len(radios)/2)374		list1 = numpy.array(radios).reshape(row,2)375		list2 = list(range(row))376		i=random.choice(list2)377		list1[i][0].click()378		list2.remove(i)379		j=random.choice(list2)		380		list1[j][1].click()381382def drag_drop(driver):383#ææ½384	#ææ½ââä¸å¯¹ä¸385	#if driver.find_elements(By.ID,"1468903112066924546"): 386	if driver.find_elements(By.CSS_SELECTOR,("div[data-rbd-draggable-id]")) and driver.find_elements(By.CLASS_NAME,"ant-checkbox"):#A-36b387		print("ææ½ââä¸å¯¹ä¸")388		sources = list(driver.find_elements(By.CLASS_NAME,"ant-checkbox"))389		targets = []390		bkgs = driver.find_elements(By.XPATH,"//div//div[starts-with(@style,'background')]")391		for bkg in bkgs:392			if bkg.find_elements(By.XPATH,"div[starts-with(@style,'margin')]"):393				targets.append(bkg.find_element(By.XPATH,"div[starts-with(@style,'background')]"))394		for source in sources:395			target = random.choice(targets)396			pyautogui.moveTo(source.location['x']+20,source.location['y']+110)397			pyautogui.dragTo(target.location['x']+20,target.location['y']+155,duration=1)398			targets.remove(target)399		sleep(1)400	#ææ½ââå¤å¯¹å¤401	# elif driver.find_elements(By.ID,"1466639248998715408") or driver.find_elements(By.ID,"1469136958168113153"):402	# elif #A54403	# 	print("ææ½ââå¤å¯¹å¤")404	# 	try:405	# 		sources = driver.find_elements(By.CSS_SELECTOR,("div[data-rbd-draggable-id]"))406	# 		targets = driver.find_elements(By.XPATH,"//div[starts-with(@style,'display')]//div[starts-with(@style,'background')]")407	# 		maxnum = len(all_targets)408	# 		for source in sources:409	# 			targets	= random.sample(all_targets,random.randint(1,maxnum))410	# 			for target in targets:411	# 				pyautogui.moveTo(source.location['x']+20,source.location['y']+125)412	# 				pyautogui.dragTo(target.location['x']+20,target.location['y']+155,duration=1)413	# 			sleep(1)414	# 	except:415	# 		pass416	#ææ½ââä¸å¯¹å¤417	#elif driver.find_elements(By.ID,"1466639248973549593") or driver.find_elements(By.ID,"1468883100002353154") or driver.find_elements(By.ID,"1469136197463244802"):418	elif driver.find_elements(By.CSS_SELECTOR,("div[data-rbd-draggable-id]")):#A35-A35a-A54-A54a419		print("ææ½ââä¸å¯¹å¤ãå¤å¯¹å¤")420		sources = driver.find_elements(By.CSS_SELECTOR,("div[data-rbd-draggable-id]"))421		all_targets = driver.find_elements(By.XPATH,"//div[starts-with(@style,'display')]//div[starts-with(@style,'background')]")422		print(sources,len(sources))423		print(all_targets,len(all_targets))424		for source in sources:425			target = random.choice(all_targets)426			pyautogui.moveTo(source.location['x']+20,source.location['y']+125)427			pyautogui.dragTo(target.location['x']+20,target.location['y']+155,duration=1)428		sleep(1)429		sources_after =  driver.find_elements(By.CSS_SELECTOR,("div[data-rbd-draggable-id]"))430		print(sources_after,len(sources_after))431		if len(sources_after) > len(sources):432			maxnum = len(all_targets)433			result = True434			while result:435				for source in sources:436					targets	= random.sample(all_targets,random.randint(1,maxnum))437					for target in targets:438						pyautogui.moveTo(source.location['x']+20,source.location['y']+125)439						pyautogui.dragTo(target.location['x']+20,target.location['y']+155,duration=1)440					sleep(1)441				list2 = []442				for target in all_targets:443					if target.find_elements(By.CSS_SELECTOR,("div[data-rbd-draggable-id]")):444						list2.append("True")445					else:446						list2.append("False")447				if "False" in list2:448					result = True449				else:450					result = False451452453454#䏿åéä¸å¯¹ä¸455def matrix_select(driver):456	#if driver.find_elements(By.ID,"1468884130500902914"):457	if driver.find_elements(By.CLASS_NAME,"matrixSelect_wrapper__2jcBe"):#A36a458		print("䏿åéä¸å¯¹ä¸")459		columns = driver.find_elements(By.CLASS_NAME,"ant-select-selector")460		for column in columns:461			column.click()462			sleep(1)463			options = driver.find_elements(By.CLASS_NAME,"ant-select-item.ant-select-item-option")[-5:]464			options_disable =driver.find_elements(By.CLASS_NAME,"ant-select-item.ant-select-item-option.ant-select-item-option-disabled") 465			list1 = list(set(options)-set(options_disable))466			option = random.choice(list1)467			option.click()468469470471472473'''474def matrix_checkbox(driver):475	#ç©éµå¤éââ翻页476	if driver.find_elements(By.ID,"1466639248990326807"):477		print("ç©éµå¤éââ翻页")478		pages = driver.find_elements(By.CSS_SELECTOR,("div[data-index]"))479		for page in pages:480			options_all = page.find_elements(By.CLASS_NAME,"ant-checkbox-input")481			options_disable = page.find_elements(By.CSS_SELECTOR,("input[disabled]"))482			options = list(set(options_all)-set(options_disable))483			num = random.randint(1,len(options))484			for option in random.sample(options,num):485				option.click()486			if driver.find_elements(By.CLASS_NAME,"anticon.anticon-right"):487				driver.find_element(By.CLASS_NAME,"anticon.anticon-right").click()488			driver.forward()489			driver.switch_to.window(driver.window_handles[0])490			sleep(1)			491	#ç©éµå¤éââé屿¾ç¤º492	elif  driver.find_elements(By.ID,"1466639248994521109"):493		print(r"ç©éµå¤éââé屿¾ç¤º")494		old_row = "None"495		while True:496			rows = driver.find_elements(By.CLASS_NAME,"ant-table-row.ant-table-row-level-0")497			row = rows[-1]498			if row == old_row:499				break500			else:501				options = row.find_elements(By.CLASS_NAME,"ant-checkbox-input")502				num = random.randint(1,len(options))503				for option in random.sample(options,num):504					option.click()505				old_row = row506	#ç©éµå¤éââåºé¨è¡äºæ¥507	if driver.find_elements(By.ID,"1466657198283608065"):508		print(r"ç©éµå¤éââåºé¨è¡äºæ¥")509		try:510			rows = driver.find_elements(By.CLASS_NAME,"ant-table-row.ant-table-row-level-0")511			for row in rows:512				options_all=row.find_elements(By.CLASS_NAME,"ant-checkbox-input")513				options_disable = row.find_elements(By.CSS_SELECTOR,("input[disabled]"))514				options = list(set(options_all)-set(options_disable))515				num = random.randint(1,len(options))516				for option in random.sample(options,num):517					option.click()518		except:519			sleep(2)520			pass521	#ç©éµå¤éââç¦ç¨ååäºæ¥522	#elif  driver.find_elements(By.ID,"1466639248986132521") or driver.find_elements(By.ID,"1466639249002909710"):523	elif  driver.find_elements(By.CLASS_NAME,"ant-table-row.ant-table-row-level-0") and driver.find_elements(By.CLASS_NAME,"ant-table.ant-table-bordered") and driver.find_elements(By.CLASS_NAME,"cell-div") and driver.find_elements(By.CLASS_NAME,"ant-table-container"): 524		print(r"ç©éµå¤éââç¦ç¨åäºæ¥")525		try:526			rows_all = driver.find_elements(By.CLASS_NAME,"ant-table-row.ant-table-row-level-0")527			rows_disable = driver.find_elements(By.CLASS_NAME,"ant-table-row.ant-table-row-level-0.custom-head")528			rows = list(set(rows_all)-set(rows_disable))529			for row in rows:530				options_all1=row.find_elements(By.CLASS_NAME,"ant-checkbox-input")531				options_disable1 = row.find_elements(By.CSS_SELECTOR,("input[disabled]"))532				options1 = list(set(options_all1)-set(options_disable1))533				option1 = random.choice(options1)534				if option1.is_selected():535					pass536				else:537					option1.click()538				sleep(1)539				options_all2 = row.find_elements(By.CLASS_NAME,"ant-checkbox-input")540				options2 = list(set(options_all2) - set(options_disable1))541				options2.remove(option1)542				maxnum = len(options2)543				num = random.randint(0,maxnum)544				for option in random.sample(options2,num):545					if option.is_selected():546						pass547					else:					548						option.click()549				sleep(2)	550		except:551			sleep(2)552			pass553	sleep(1)554'''555def matrix_checkbox(driver):556		#ç©éµå¤éââ翻页557	#if driver.find_elements(By.ID,"1466639248990326807"):558	if driver.find_elements(By.XPATH,"//div[starts-with(@class,'matrixCard')]") and driver.find_elements(By.CLASS_NAME,"slick-list") and driver.find_elements(By.CLASS_NAME,"matrix-checkbox") and driver.find_elements(By.CLASS_NAME,"slick-slide"):#A52559		print("ç©éµå¤éââ翻页")560		pages = driver.find_elements(By.CSS_SELECTOR,("div[data-index]"))561		for page in pages:562			options_all = page.find_elements(By.CLASS_NAME,"ant-checkbox-input")563			options_disable = page.find_elements(By.CSS_SELECTOR,("input[disabled]"))564			options = list(set(options_all)-set(options_disable))565			num = random.randint(1,len(options))566			for option in random.sample(options,num):567				option.click()568			if driver.find_elements(By.CLASS_NAME,"anticon.anticon-right"):569				driver.find_element(By.CLASS_NAME,"anticon.anticon-right").click()570			driver.forward()571			driver.switch_to.window(driver.window_handles[0])572			sleep(1)			573	elif  driver.find_elements(By.CLASS_NAME,"ant-table-row.ant-table-row-level-0") and driver.find_elements(By.CLASS_NAME,"ant-table.ant-table-bordered") and driver.find_elements(By.CLASS_NAME,"cell-div") and driver.find_elements(By.CLASS_NAME,"ant-table-container"): #A51-A51b-A53-A55574		print(r"ç©éµå¤éââç¦ç¨ãäºæ¥ãéæ¾")575		rows_all = driver.find_elements(By.CLASS_NAME,"ant-table-row.ant-table-row-level-0")576		rows_disable = driver.find_elements(By.CLASS_NAME,"ant-table-row.ant-table-row-level-0.custom-head")577		rows = list(set(rows_all)-set(rows_disable))578		for row in rows:579			if row.find_elements(By.CLASS_NAME,"ant-checkbox-input"):580				options_all = row.find_elements(By.CLASS_NAME,"ant-checkbox-input")581				options_disable = row.find_elements(By.CSS_SELECTOR,("input[disabled]"))582				options = list(set(options_all)-set(options_disable))583				print(options_all)584				print(options_disable)585				print(options)586				option =random.choice(options)587				if option.is_selected():588					pass589				else:590					option.click()591				sleep(1)592				options_all2 = row.find_elements(By.CLASS_NAME,"ant-checkbox-input")593				options2 = list(set(options_all2) - set(options_disable))594				options2.remove(option)595				maxnum = len(options2)596				num = random.randint(0,maxnum)597				for option in random.sample(options2,num):598					if option.is_selected():599						pass600					else:					601						option.click()602				sleep(2)603		while True:604			rows_old = rows_all605			old_row = len(rows_all)606			rows_all = driver.find_elements(By.CLASS_NAME,"ant-table-row.ant-table-row-level-0")607			new_row = len(rows_all)	608			if new_row == old_row:609				break610			else:611				last_rows = list(set(rows_all) - set(rows_old))612				last_row = last_rows[-1]613				options_all = last_row.find_elements(By.CLASS_NAME,"ant-checkbox-input")614				options_disable = last_row.find_elements(By.CSS_SELECTOR,("input[disabled]"))615				options = list(set(options_all)-set(options_disable))616				option =random.choice(options)617				if option.is_selected():618					pass619				else:620					option.click()621				sleep(1)622				options_all2 = last_row.find_elements(By.CLASS_NAME,"ant-checkbox-input")623				options2 = list(set(options_all2) - set(options_disable))624				options2.remove(option)625				maxnum = len(options2)626				num = random.randint(0,maxnum)627				for option in random.sample(options2,num):628					if option.is_selected():629						pass630					else:					631						option.click()632				rows_old=rows_all633				sleep(2)634	elif driver.find_elements(By.CLASS_NAME,"base-checkbox") and driver.find_elements(By.CLASS_NAME,"ant-checkbox"):  #A4-A56635		print("å¤éäºæ¥")636		maxnum = 4637		options1 = driver.find_elements(By.CLASS_NAME,"ant-checkbox-input")638		option1 = random.choice(options1)639		sleep(1)640		option1.click()641		options2 = driver.find_elements(By.CLASS_NAME,"ant-checkbox-input")642		options2.remove(option1)643		if options2:644			num = random.randrange(maxnum)645			options = random.sample(options2,num)646			for option in options:647				option.click()648		sleep(2)649	650651652653def read_input():654	#print(r"https://answer.91question.com/91/27c6cde183c14131ba15a98d377eb918?test=1")655	#cycs = int(input("请è¾å
¥éè¦å¾ªç¯ç次æ°ï¼"))656	#url = str(input("请è¾å
¥éè¦æµè¯çç½åï¼"))657	#url = '\"'+http+'\"'	658	url = "https://answer.91question.com/91/27c6cde183c14131ba15a98d377eb918?test=1"659	cycs = int(1)660	return cycs,url661662def show_title(driver):663	if driver.find_element(By.CLASS_NAME,"survey-title").text == "ç»æé¡µ":664		pass665	else:666		title1 = driver.find_element(By.CLASS_NAME,"q-title-code").text667		title2 = driver.find_element(By.CLASS_NAME,"QTitle_q_title_text__3cVtW").text668		print(f"ç°å¨æä½é¢ç®ï¼{title1}{title2}")669670671672if __name__ == '__main__':673	breaknum = 0674	finnum = 0675	errnum = 0676	cycs,url = read_input()677	for cyc in range(cycs):678		result = 0679		driver = get_url(url)680		while True:681			sleep(1)682			show_title(driver)683			if driver.find_elements(By.CLASS_NAME,"matrix-radio") and driver.find_elements(By.CLASS_NAME,"q-matrix-content"): #A34-A34a			684				radio_page(driver)685			else:686				single_radio(driver)687688			list_boxs(driver)689			dropdown_radio(driver)690			matrix_radio(driver)691			maxdiff_row(driver)		692			693			drag_drop(driver)694			matrix_select(driver)		695			matrix_checkbox(driver)696			ant_input(driver)697			result = next_page(driver)
...91question.py
Source:91question.py  
...17	driver.maximize_window()18	while True:	19		driver.get(url)20		sleep(1)21		if driver.find_elements(By.CLASS_NAME,"ant-radio-input"):22			return driver23			break2425#翻页ãä¸æãæ¥é26def next_page(driver):27	if driver.find_elements(By.CSS_SELECTOR,"a[role=\"button\"]"):28		print("翻页ãä¸æãæ¥é")29		nextpage=driver.find_element(By.CSS_SELECTOR,"a[role=\"button\"]")30#		nextpage.click()31#		driver.switch_to.window(driver.window_handles[0])32#		return 0				33#	else:34#		return 135		try:36			nextpage.click()37		except:38			pass39		else:40			driver.switch_to.window(driver.window_handles[0])41			return 042	elif driver.find_elements(By.XPATH,"//*[contains(text(),'æè°¢æ¨åå æ¬æ¬¡æ´»å¨')]"):43		driver.quit()44		return 245	elif driver.find_elements(By.XPATH,"//*[contains(text(),'å¾éæ¾æ¨ä¸ç¬¦åæ¬æ¬¡æ´»å¨è¦æ±')]"):46		driver.quit()47		return 148	else:49		return 35051#åé52def single_radio(diver):53	if driver.find_elements(By.ID,"1468879590070353922") or driver.find_elements(By.ID,"1466615958692044801") or driver.find_elements(By.ID,"1468427864989114369") or driver.find_elements(By.ID,"1468429089340006402"):  54		print("åé")55		radios1 = driver.find_elements(By.CLASS_NAME,"ant-radio-input")56		radios2 = driver.find_elements(By.CSS_SELECTOR,("input[disabled]"))57		radios = list(set(radios1)-set(radios2))58		radio = random.choice(radios)59		radio.click()606162#䏿å表åé63def list_box(driver,id,xpath1,xpath2):64	if driver.find_elements(By.CLASS_NAME,"ant-select-selector"):65		print("䏿å表åé")66		if driver.find_elements(By.ID,id):67			listbox = driver.find_element(By.ID,id)68			listbox.click()69			if len(driver.find_elements(By.XPATH,xpath1)) > 8:70				m=random.randint(0,20)71				for i in range(m):72					drag = driver.find_element(By.XPATH,xpath2)73					ActionChains(driver).drag_and_drop_by_offset(drag,0,10).perform()74					#driver.implicitly_wait(5)75				elements = driver.find_elements(By.XPATH,xpath1)76				element = random.choice(elements[1:-2])77				sleep(1)78				element.click()	79			else:80				elements = driver.find_elements(By.XPATH,xpath1)81				element = random.choice(elements)82				sleep(1)83				element.click()	8485#ä¸¤ä¸ªä¸æé¿å表åé86def list_boxs(driver):87	if driver.find_elements(By.ID,"1468879590070353922"): 88		print("ä¸¤ä¸ªä¸æé¿å表åé")89		list_box(driver,"rc_select_0","/html/body/div[2]/div/div/div/div[2]/div[1]/div/div/div","/html/body/div[2]/div/div/div/div[2]/div[2]/div")90		list_box(driver,"rc_select_1","/html/body/div[3]/div/div/div/div[2]/div[1]/div/div/div","/html/body/div[3]/div/div/div/div[2]/div[2]/div")91	92	elif driver.find_elements(By.ID,"1468880360681439234"):93		print("ä¸¤ä¸ªä¸æé¿å表åé")94		list_box(driver,"rc_select_2","/html/body/div[2]/div/div/div/div[2]/div[1]/div/div/div","/html/body/div[2]/div/div/div/div[2]/div[2]/div")95		list_box(driver,"rc_select_3","/html/body/div[3]/div/div/div/div[2]/div[1]/div/div/div","/html/body/div[3]/div/div/div/div[2]/div[2]/div")96	97	98	#sleep(1)99100#䏿åé101def dropdown_radio(driver):102	if driver.find_elements(By.ID,"1466616122777411586"):   103		print("䏿åé")104		options = Select(driver.find_element(By.TAG_NAME,"select"))105		number = random.randint(1,len(options.options)-1)106		options.select_by_index(number)	107108	109110def matrix_radio(driver):111	#ç©éµåéï¼å«ç¦ç¨ï¼112	if	driver.find_elements(By.ID,"1466616582926114818") or driver.find_elements(By.ID,"1466639248965160964") or driver.find_elements(By.ID,"1466639248977743895"):113		try:114			print("ç©éµåé")115			radios1 = driver.find_elements(By.CLASS_NAME,"ant-radio-input")116			radios1_disable = driver.find_elements(By.CSS_SELECTOR,("input[disabled]"))117			row = len(driver.find_elements(By.TAG_NAME,"li"))-1118			column = int(len(radios1)/row)119			list1 = numpy.array(radios1).reshape(row,column)120			if radios1_disable:121				for i in range(row):122					list2=[]123					for j in range(column):124						for radio_disable in radios1_disable:125							if list1[i][j] != radio_disable:126								list2.append(list1[i][j])127					radio = random.choice(list2)128					radio.click()129			else:130				for i in range(row):131					radio = random.choice(list1[i])132					radio.click()133		except:134			pass135	elif driver.find_elements(By.ID,"1466642621613395969") or driver.find_elements(By.ID,"1469128974213251073") or driver.find_elements(By.ID,"1469131169214169089"):136		print("ç©éµåéï¼ä¸ä¸å·¦å³å¯ä¸ï¼")137		radios = driver.find_elements(By.CLASS_NAME,"matrix_openContainer__1xqzZ")138		row_all = len(driver.find_elements(By.TAG_NAME,"li"))139		row_disable = len(driver.find_elements(By.CLASS_NAME,"matrix_titleRow__3Ab16"))140		row = int(row_all - row_disable)141		column = int(len(radios)/row)142		list1 = numpy.array(radios).reshape(row,column)143		for i in range(row):144			for j in range(column):145				if list1[i][j].get_attribute('innerHTML'):146					pass147				else:148					list1[i][j] = False149		list2 = list(range(column))150		if row > column:151			rows = random.sample(range(row),column)152		else:153			rows = range(row)154		for i in rows:	155			for j in list2:156				list3=list2157				if list1[i][j]:158					pass159				else:160					list3.remove(j)161			k = random.choice(list3)162			list1[i][k].click()163			list2.remove(k)164165def ant_input(driver):166	#è¾å
¥ææ¬167	if driver.find_elements(By.ID,"1466639249007104011"):168		for i in [1,2,3,4]:169			ele =  driver.find_element(By.XPATH,f"/html/body/div/div/div[2]/div/div/div[1]/div/div[2]/div/div/div/div[{i}]/section/div/input")170			if ele.get_attribute('value'):171				pass172			else:173				if i == 2:174					ele.send_keys(random.randint(1,10))175				elif i == 3:176					ele.send_keys(random.randint(1,100))177				else:178					ele.send_keys("Bruce test!")179	elif driver.find_elements(By.ID,"1469209486710415361"):180		for i in [2,3]:181			for j in [2,3,4,5]:182				ele = driver.find_element(By.XPATH,f"/html/body/div/div/div[2]/div/div/div[1]/div/div[2]/ul/li[{i}]/div[{j}]/div/input")183				if ele.get_attribute('value'):184					pass185				else:186					if (i == 2 and j == 3) or (i ==3 and j == 3):187						ele.send_keys(random.randint(1,10))188					elif (i == 2 and j == 4) or (i ==3 and j == 4):	189						ele.send_keys(random.randint(1,100))190					else:191						ele.send_keys("Bruce test!")192	elif driver.find_elements(By.CLASS_NAME,"ant-input"):193		for i in driver.find_elements(By.CLASS_NAME,"ant-input"):194			i.send_keys("Bruce test!")195196197198199200def radio_page(driver):201#å¤é¡µåéï¼å«ç¦ç¨ï¼202	if driver.find_elements(By.ID,"1466639248969355294") or driver.find_elements(By.ID,"1468882776676040706"):203		radios = list(driver.find_elements(By.CLASS_NAME,"ant-radio-input"))204		print(r"å¤é¡µåéï¼å«ç¦ç¨ï¼")205		radios_disable = driver.find_elements(By.CSS_SELECTOR,("input[disabled]"))206		row = len(driver.find_elements(By.CSS_SELECTOR,("div[data-index]")))207		column = int(len(radios)/row)208		list1 = numpy.array(radios).reshape(row,column)209		if radios_disable:210			for i in range(row):211				list2=[]212				for j in range(column):213					for radio_disable in radios_disable:214						if list1[i][j] != radio_disable:215							list2.append(list1[i][j])216				radio = random.choice(list2)217				radio.click()218				if driver.find_elements(By.CLASS_NAME,"ant-radio.ant-radio-checked") and driver.find_elements(By.CLASS_NAME,"anticon.anticon-right"):219					driver.find_element(By.CLASS_NAME,"anticon.anticon-right").click()220				driver.forward()221				driver.switch_to.window(driver.window_handles[0])222				sleep(1)			223		else:224			for i in range(row):225				radio = random.choice(list1[i])226				radio.click()227				if driver.find_elements(By.CLASS_NAME,"ant-radio.ant-radio-checked") and driver.find_elements(By.CLASS_NAME,"anticon.anticon-right"):228					driver.find_element(By.CLASS_NAME,"anticon.anticon-right").click()229				driver.forward()230				driver.switch_to.window(driver.window_handles[0])231				sleep(1)232233234def maxdiff_row(driver):235#å·¦å³åé236	if driver.find_elements(By.ID,"1466639248969355272"):237		print("å·¦å³åé")238		radios = list(driver.find_elements(By.CLASS_NAME,"ant-radio-input"))239		row=int(len(radios)/2)240		list1 = numpy.array(radios).reshape(row,2)241		list2 = list(range(row))242		i=random.choice(list2)243		list1[i][0].click()244		list2.remove(i)245		j=random.choice(list2)		246		list1[j][1].click()247248def drag_drop(driver):249#ææ½250	#ææ½ââä¸å¯¹ä¸251	if driver.find_elements(By.ID,"1468903112066924546"): 252		print("ææ½ââä¸å¯¹ä¸")253		sources = list(driver.find_elements(By.CLASS_NAME,"ant-checkbox"))254		targets = []255		for i in range(1,4):256			targets.append(driver.find_element(By.XPATH,f"/html/body/div[1]/div/div[2]/div/div/div[1]/div/div[2]/div/div[{i}]/div[2]"))257		for source in sources:258			target = random.choice(targets)259			pyautogui.moveTo(source.location['x']+20,source.location['y']+110)260			pyautogui.dragTo(target.location['x']+20,target.location['y']+155,duration=1)261			targets.remove(target)262		sleep(1)263	#ææ½ââå¤å¯¹å¤264	elif driver.find_elements(By.ID,"1466639248998715408") or driver.find_elements(By.ID,"1469136958168113153"):265		print("ææ½ââå¤å¯¹å¤")266		try:267			sources = driver.find_elements(By.CSS_SELECTOR,("div[data-rbd-draggable-id]"))268			all_targets = []269			for i in range(1,6):270				all_targets.append(driver.find_element(By.XPATH,f"/html/body/div[1]/div/div[2]/div/div/div[1]/div/div[2]/div[3]/div[{i}]"))271			maxnum = len(all_targets)272			for source in sources:273				targets	= random.sample(all_targets,random.randint(1,maxnum))274				for target in targets:275					pyautogui.moveTo(source.location['x']+20,source.location['y']+125)276					pyautogui.dragTo(target.location['x']+20,target.location['y']+155,duration=1)277				sleep(1)278		except:279			pass280	#ææ½ââä¸å¯¹å¤281	elif driver.find_elements(By.ID,"1466639248973549593") or driver.find_elements(By.ID,"1468883100002353154") or driver.find_elements(By.ID,"1469136197463244802"):282		print("ææ½ââä¸å¯¹å¤")283		sources = driver.find_elements(By.CSS_SELECTOR,("div[data-rbd-draggable-id]"))284		targets = []285		for i in range(1,6):286			targets.append(driver.find_element(By.XPATH,f"/html/body/div[1]/div/div[2]/div/div/div[1]/div/div[2]/div[3]/div[{i}]"))287		for source in sources:288			target = random.choice(targets)289			pyautogui.moveTo(source.location['x']+20,source.location['y']+125)290			pyautogui.dragTo(target.location['x']+20,target.location['y']+155,duration=1)291		sleep(1)292293294295#䏿åéä¸å¯¹ä¸296def matrix_select(driver):297	if driver.find_elements(By.ID,"1468884130500902914"):298		print("䏿åéä¸å¯¹ä¸")299		columns = driver.find_elements(By.CLASS_NAME,"ant-select-selector")300		for column in columns:301			column.click()302			sleep(1)303			options = driver.find_elements(By.CLASS_NAME,"ant-select-item.ant-select-item-option")[-5:]304			options_disable =driver.find_elements(By.CLASS_NAME,"ant-select-item.ant-select-item-option.ant-select-item-option-disabled") 305			list1 = list(set(options)-set(options_disable))306			option = random.choice(list1)307			option.click()308309310311312def ant_checkbox(driver,maxnum):313	#å¤éäºæ¥	314	print("å¤éäºæ¥")315	options1 = driver.find_elements(By.CLASS_NAME,"ant-checkbox-input")316	option1 = random.choice(options1)317	sleep(1)318	option1.click()319	options2 = driver.find_elements(By.CLASS_NAME,"ant-checkbox-input")320	options2.remove(option1)321	if options2:322		num = random.randrange(maxnum)323		options = random.sample(options2,num)324		for option in options:325			option.click()326	sleep(2)327328329def matrix_checkbox(driver):330	#ç©éµå¤éââ翻页331	if driver.find_elements(By.ID,"1466639248990326807"):332		print("ç©éµå¤éââ翻页")333		pages = driver.find_elements(By.CSS_SELECTOR,("div[data-index]"))334		for page in pages:335			options_all = page.find_elements(By.CLASS_NAME,"ant-checkbox-input")336			options_disable = page.find_elements(By.CSS_SELECTOR,("input[disabled]"))337			options = list(set(options_all)-set(options_disable))338			num = random.randint(1,len(options))339			for option in random.sample(options,num):340				option.click()341			if driver.find_elements(By.CLASS_NAME,"anticon.anticon-right"):342				driver.find_element(By.CLASS_NAME,"anticon.anticon-right").click()343			driver.forward()344			driver.switch_to.window(driver.window_handles[0])345			sleep(1)			346	#ç©éµå¤éââé屿¾ç¤º347	elif  driver.find_elements(By.ID,"1466639248994521109"):348		print(r"ç©éµå¤éââé屿¾ç¤º")349		old_row = "None"350		while True:351			rows = driver.find_elements(By.CLASS_NAME,"ant-table-row.ant-table-row-level-0")352			row = rows[-1]353			if row == old_row:354				break355			else:356				options = row.find_elements(By.CLASS_NAME,"ant-checkbox-input")357				num = random.randint(1,len(options))358				for option in random.sample(options,num):359					option.click()360				old_row = row361	#ç©éµå¤éââåºé¨è¡äºæ¥362	if driver.find_elements(By.ID,"1466657198283608065"):363		print(r"ç©éµå¤éââåºé¨è¡äºæ¥")364		try:365			rows = driver.find_elements(By.CLASS_NAME,"ant-table-row.ant-table-row-level-0")366			for row in rows:367				options_all=row.find_elements(By.CLASS_NAME,"ant-checkbox-input")368				options_disable = row.find_elements(By.CSS_SELECTOR,("input[disabled]"))369				options = list(set(options_all)-set(options_disable))370				num = random.randint(1,len(options))371				for option in random.sample(options,num):372					option.click()373		except:374			sleep(2)375			pass376	#ç©éµå¤éââç¦ç¨ååäºæ¥377	elif  driver.find_elements(By.ID,"1466639248986132521") or driver.find_elements(By.ID,"1466639249002909710"):378		print(r"ç©éµå¤éââç¦ç¨ååäºæ¥")379		try:380			rows_all = driver.find_elements(By.CLASS_NAME,"ant-table-row.ant-table-row-level-0")381			rows_disable = driver.find_elements(By.CLASS_NAME,"ant-table-row.ant-table-row-level-0.custom-head")382			rows = list(set(rows_all)-set(rows_disable))383			for row in rows:384				options_all1=row.find_elements(By.CLASS_NAME,"ant-checkbox-input")385				options_disable1 = row.find_elements(By.CSS_SELECTOR,("input[disabled]"))386				options1 = list(set(options_all1)-set(options_disable1))387				option1 = random.choice(options1)388				if option1.is_selected():389					pass390				else:391					option1.click()392				sleep(1)393				options_all2 = row.find_elements(By.CLASS_NAME,"ant-checkbox-input")394				options2 = list(set(options_all2) - set(options_disable1))395				options2.remove(option1)396				maxnum = len(options2)397				num = random.randint(0,maxnum)398				for option in random.sample(options2,num):399					if option.is_selected():400						pass401					else:					402						option.click()403				sleep(2)	404		except:405			sleep(2)406			pass407	sleep(1)408409def read_input():410	print(r"https://answer.91question.com/91/27c6cde183c14131ba15a98d377eb918?test=1")411	cycs = int(input("请è¾å
¥éè¦å¾ªç¯ç次æ°ï¼"))412	url = str(input("请è¾å
¥éè¦æµè¯çç½åï¼"))413	#url = '\"'+http+'\"'	414	#url = "https://answer.91question.com/91/27c6cde183c14131ba15a98d377eb918?test=1"415	#cycs = int(5)416	return cycs,url417418419420if __name__ == '__main__':421	breaknum = 0422	finnum = 0423	errnum = 0424	cycs,url = read_input()425	for cyc in range(cycs):426		result = 0427		driver = get_url(url)428		while True:429			sleep(1)430			single_radio(driver)431			list_boxs(driver)432			dropdown_radio(driver)433			matrix_radio(driver)434			maxdiff_row(driver)		435			radio_page(driver)436			drag_drop(driver)437			matrix_select(driver)		438			matrix_checkbox(driver)439			if driver.find_elements(By.ID,"1466639248986132497"):440				ant_checkbox(driver,4)441			elif driver.find_elements(By.ID,"1469128264033697794"):442				ant_checkbox(driver,5)443			ant_input(driver)444			result = next_page(driver)445			if result == 1:446				breaknum += 1447				break448			elif result == 2:449				finnum += 1450				break	451			elif result == 0:452				pass453			elif result == 3:454				errnum += 1455				break		
...91test_bk.py
Source:91test_bk.py  
...17	driver.maximize_window()18	while True:	19		driver.get(url)20		sleep(1)21		if driver.find_elements(By.CLASS_NAME,"ant-radio-input"):22			return driver23			break2425#翻页ãä¸æãæ¥é26def next_page(driver):27	if driver.find_elements(By.CSS_SELECTOR,"a[role=\"button\"]"):28		print("翻页ãä¸æãæ¥é")29		nextpage=driver.find_element(By.CSS_SELECTOR,"a[role=\"button\"]")30#		nextpage.click()31#		driver.switch_to.window(driver.window_handles[0])32#		return 0				33#	else:34#		return 135		try:36			nextpage.click()37		except:38			pass39		else:40			driver.switch_to.window(driver.window_handles[0])41			return 042	elif driver.find_elements(By.XPATH,"//*[contains(text(),'æè°¢æ¨åå æ¬æ¬¡æ´»å¨')]"):43		driver.quit()44		return 245	elif driver.find_elements(By.XPATH,"//*[contains(text(),'å¾éæ¾æ¨ä¸ç¬¦åæ¬æ¬¡æ´»å¨è¦æ±')]"):46		driver.quit()47		return 148	else:49		return 35051#åé52def single_radio(diver):53	if driver.find_elements(By.ID,"1468879590070353922") or driver.find_elements(By.ID,"1466615958692044801") or driver.find_elements(By.ID,"1468427864989114369") or driver.find_elements(By.ID,"1468429089340006402"):  54		print("åé")55		radios1 = driver.find_elements(By.CLASS_NAME,"ant-radio-input")56		radios2 = driver.find_elements(By.CSS_SELECTOR,("input[disabled]"))57		radios = list(set(radios1)-set(radios2))58		radio = random.choice(radios)59		radio.click()606162#䏿å表åé63def list_box(driver,id,xpath1,xpath2):64	if driver.find_elements(By.CLASS_NAME,"ant-select-selector"):65		print("䏿å表åé")66		if driver.find_elements(By.ID,id):67			listbox = driver.find_element(By.ID,id)68			listbox.click()69			if len(driver.find_elements(By.XPATH,xpath1)) > 8:70				m=random.randint(0,20)71				for i in range(m):72					drag = driver.find_element(By.XPATH,xpath2)73					ActionChains(driver).drag_and_drop_by_offset(drag,0,10).perform()74					#driver.implicitly_wait(5)75				elements = driver.find_elements(By.XPATH,xpath1)76				element = random.choice(elements[1:-2])77				sleep(1)78				element.click()	79			else:80				elements = driver.find_elements(By.XPATH,xpath1)81				element = random.choice(elements)82				sleep(1)83				element.click()	8485#ä¸¤ä¸ªä¸æé¿å表åé86def list_boxs(driver):87	if driver.find_elements(By.ID,"1468879590070353922"): 88		print("ä¸¤ä¸ªä¸æé¿å表åé")89		list_box(driver,"rc_select_0","/html/body/div[2]/div/div/div/div[2]/div[1]/div/div/div","/html/body/div[2]/div/div/div/div[2]/div[2]/div")90		list_box(driver,"rc_select_1","/html/body/div[3]/div/div/div/div[2]/div[1]/div/div/div","/html/body/div[3]/div/div/div/div[2]/div[2]/div")91	92	elif driver.find_elements(By.ID,"1468880360681439234"):93		print("ä¸¤ä¸ªä¸æé¿å表åé")94		list_box(driver,"rc_select_2","/html/body/div[2]/div/div/div/div[2]/div[1]/div/div/div","/html/body/div[2]/div/div/div/div[2]/div[2]/div")95		list_box(driver,"rc_select_3","/html/body/div[3]/div/div/div/div[2]/div[1]/div/div/div","/html/body/div[3]/div/div/div/div[2]/div[2]/div")96	97	98	#sleep(1)99100#䏿åé101def dropdown_radio(driver):102	if driver.find_elements(By.ID,"1466616122777411586"):   103		print("䏿åé")104		options = Select(driver.find_element(By.TAG_NAME,"select"))105		number = random.randint(1,len(options.options)-1)106		options.select_by_index(number)	107108	109110def matrix_radio(driver):111	#ç©éµåéï¼å«ç¦ç¨ï¼112	if	driver.find_elements(By.ID,"1466616582926114818") or driver.find_elements(By.ID,"1466639248965160964") or driver.find_elements(By.ID,"1466639248977743895"):113		try:114			print("ç©éµåé")115			radios1 = driver.find_elements(By.CLASS_NAME,"ant-radio-input")116			radios1_disable = driver.find_elements(By.CSS_SELECTOR,("input[disabled]"))117			row = len(driver.find_elements(By.TAG_NAME,"li"))-1118			column = int(len(radios1)/row)119			list1 = numpy.array(radios1).reshape(row,column)120			if radios1_disable:121				for i in range(row):122					list2=[]123					for j in range(column):124						for radio_disable in radios1_disable:125							if list1[i][j] != radio_disable:126								list2.append(list1[i][j])127					radio = random.choice(list2)128					radio.click()129			else:130				for i in range(row):131					radio = random.choice(list1[i])132					radio.click()133		except:134			pass135	elif driver.find_elements(By.ID,"1466642621613395969") or driver.find_elements(By.ID,"1469128974213251073") or driver.find_elements(By.ID,"1469131169214169089"):136		print("ç©éµåéï¼ä¸ä¸å·¦å³å¯ä¸ï¼")137		radios = driver.find_elements(By.CLASS_NAME,"matrix_openContainer__1xqzZ")138		row_all = len(driver.find_elements(By.TAG_NAME,"li"))139		row_disable = len(driver.find_elements(By.CLASS_NAME,"matrix_titleRow__3Ab16"))140		row = int(row_all - row_disable)141		column = int(len(radios)/row)142		list1 = numpy.array(radios).reshape(row,column)143		for i in range(row):144			for j in range(column):145				if list1[i][j].get_attribute('innerHTML'):146					pass147				else:148					list1[i][j] = False149		list2 = list(range(column))150		if row > column:151			rows = random.sample(range(row),column)152		else:153			rows = range(row)154		for i in rows:	155			for j in list2:156				list3=list2157				if list1[i][j]:158					pass159				else:160					list3.remove(j)161			k = random.choice(list3)162			list1[i][k].click()163			list2.remove(k)164165def ant_input(driver):166	#è¾å
¥ææ¬167	if driver.find_elements(By.ID,"1466639249007104011"):168		for i in [1,2,3,4]:169			ele =  driver.find_element(By.XPATH,f"/html/body/div/div/div[2]/div/div/div[1]/div/div[2]/div/div/div/div[{i}]/section/div/input")170			if ele.get_attribute('value'):171				pass172			else:173				if i == 2:174					ele.send_keys(random.randint(1,10))175				elif i == 3:176					ele.send_keys(random.randint(1,100))177				else:178					ele.send_keys("Bruce test!")179	elif driver.find_elements(By.ID,"1469209486710415361"):180		for i in [2,3]:181			for j in [2,3,4,5]:182				ele = driver.find_element(By.XPATH,f"/html/body/div/div/div[2]/div/div/div[1]/div/div[2]/ul/li[{i}]/div[{j}]/div/input")183				if ele.get_attribute('value'):184					pass185				else:186					if (i == 2 and j == 3) or (i ==3 and j == 3):187						ele.send_keys(random.randint(1,10))188					elif (i == 2 and j == 4) or (i ==3 and j == 4):	189						ele.send_keys(random.randint(1,100))190					else:191						ele.send_keys("Bruce test!")192	elif driver.find_elements(By.CLASS_NAME,"ant-input"):193		for i in driver.find_elements(By.CLASS_NAME,"ant-input"):194			i.send_keys("Bruce test!")195196197198199200def radio_page(driver):201#å¤é¡µåéï¼å«ç¦ç¨ï¼202	if driver.find_elements(By.ID,"1466639248969355294") or driver.find_elements(By.ID,"1468882776676040706"):203		radios = list(driver.find_elements(By.CLASS_NAME,"ant-radio-input"))204		print(r"å¤é¡µåéï¼å«ç¦ç¨ï¼")205		radios_disable = driver.find_elements(By.CSS_SELECTOR,("input[disabled]"))206		row = len(driver.find_elements(By.CSS_SELECTOR,("div[data-index]")))207		column = int(len(radios)/row)208		list1 = numpy.array(radios).reshape(row,column)209		if radios_disable:210			for i in range(row):211				list2=[]212				for j in range(column):213					for radio_disable in radios_disable:214						if list1[i][j] != radio_disable:215							list2.append(list1[i][j])216				radio = random.choice(list2)217				radio.click()218				if driver.find_elements(By.CLASS_NAME,"ant-radio.ant-radio-checked") and driver.find_elements(By.CLASS_NAME,"anticon.anticon-right"):219					driver.find_element(By.CLASS_NAME,"anticon.anticon-right").click()220				driver.forward()221				driver.switch_to.window(driver.window_handles[0])222				sleep(1)			223		else:224			for i in range(row):225				radio = random.choice(list1[i])226				radio.click()227				if driver.find_elements(By.CLASS_NAME,"ant-radio.ant-radio-checked") and driver.find_elements(By.CLASS_NAME,"anticon.anticon-right"):228					driver.find_element(By.CLASS_NAME,"anticon.anticon-right").click()229				driver.forward()230				driver.switch_to.window(driver.window_handles[0])231				sleep(1)232233234def maxdiff_row(driver):235#å·¦å³åé236	if driver.find_elements(By.ID,"1466639248969355272"):237		print("å·¦å³åé")238		radios = list(driver.find_elements(By.CLASS_NAME,"ant-radio-input"))239		row=int(len(radios)/2)240		list1 = numpy.array(radios).reshape(row,2)241		list2 = list(range(row))242		i=random.choice(list2)243		list1[i][0].click()244		list2.remove(i)245		j=random.choice(list2)		246		list1[j][1].click()247248def drag_drop(driver):249#ææ½250	#ææ½ââä¸å¯¹ä¸251	if driver.find_elements(By.ID,"1468903112066924546"): 252		print("ææ½ââä¸å¯¹ä¸")253		sources = list(driver.find_elements(By.CLASS_NAME,"ant-checkbox"))254		targets = []255		for i in range(1,4):256			targets.append(driver.find_element(By.XPATH,f"/html/body/div[1]/div/div[2]/div/div/div[1]/div/div[2]/div/div[{i}]/div[2]"))257		for source in sources:258			target = random.choice(targets)259			pyautogui.moveTo(source.location['x']+20,source.location['y']+110)260			pyautogui.dragTo(target.location['x']+20,target.location['y']+155,duration=1)261			targets.remove(target)262		sleep(1)263	#ææ½ââå¤å¯¹å¤264	elif driver.find_elements(By.ID,"1466639248998715408") or driver.find_elements(By.ID,"1469136958168113153"):265		print("ææ½ââå¤å¯¹å¤")266		try:267			sources = driver.find_elements(By.CSS_SELECTOR,("div[data-rbd-draggable-id]"))268			all_targets = []269			for i in range(1,6):270				all_targets.append(driver.find_element(By.XPATH,f"/html/body/div[1]/div/div[2]/div/div/div[1]/div/div[2]/div[3]/div[{i}]"))271			maxnum = len(all_targets)272			for source in sources:273				targets	= random.sample(all_targets,random.randint(1,maxnum))274				for target in targets:275					pyautogui.moveTo(source.location['x']+20,source.location['y']+125)276					pyautogui.dragTo(target.location['x']+20,target.location['y']+155,duration=1)277				sleep(1)278		except:279			pass280	#ææ½ââä¸å¯¹å¤281	elif driver.find_elements(By.ID,"1466639248973549593") or driver.find_elements(By.ID,"1468883100002353154") or driver.find_elements(By.ID,"1469136197463244802"):282		print("ææ½ââä¸å¯¹å¤")283		sources = driver.find_elements(By.CSS_SELECTOR,("div[data-rbd-draggable-id]"))284		targets = []285		for i in range(1,6):286			targets.append(driver.find_element(By.XPATH,f"/html/body/div[1]/div/div[2]/div/div/div[1]/div/div[2]/div[3]/div[{i}]"))287		for source in sources:288			target = random.choice(targets)289			pyautogui.moveTo(source.location['x']+20,source.location['y']+125)290			pyautogui.dragTo(target.location['x']+20,target.location['y']+155,duration=1)291		sleep(1)292293294295#䏿åéä¸å¯¹ä¸296def matrix_select(driver):297	if driver.find_elements(By.ID,"1468884130500902914"):298		print("䏿åéä¸å¯¹ä¸")299		columns = driver.find_elements(By.CLASS_NAME,"ant-select-selector")300		for column in columns:301			column.click()302			sleep(1)303			options = driver.find_elements(By.CLASS_NAME,"ant-select-item.ant-select-item-option")[-5:]304			options_disable =driver.find_elements(By.CLASS_NAME,"ant-select-item.ant-select-item-option.ant-select-item-option-disabled") 305			list1 = list(set(options)-set(options_disable))306			option = random.choice(list1)307			option.click()308309310311312def ant_checkbox(driver,maxnum):313	#å¤éäºæ¥	314	print("å¤éäºæ¥")315	options1 = driver.find_elements(By.CLASS_NAME,"ant-checkbox-input")316	option1 = random.choice(options1)317	sleep(1)318	option1.click()319	options2 = driver.find_elements(By.CLASS_NAME,"ant-checkbox-input")320	options2.remove(option1)321	if options2:322		num = random.randrange(maxnum)323		options = random.sample(options2,num)324		for option in options:325			option.click()326	sleep(2)327328329def matrix_checkbox(driver):330	#ç©éµå¤éââ翻页331	if driver.find_elements(By.ID,"1466639248990326807"):332		print("ç©éµå¤éââ翻页")333		pages = driver.find_elements(By.CSS_SELECTOR,("div[data-index]"))334		for page in pages:335			options_all = page.find_elements(By.CLASS_NAME,"ant-checkbox-input")336			options_disable = page.find_elements(By.CSS_SELECTOR,("input[disabled]"))337			options = list(set(options_all)-set(options_disable))338			num = random.randint(1,len(options))339			for option in random.sample(options,num):340				option.click()341			if driver.find_elements(By.CLASS_NAME,"anticon.anticon-right"):342				driver.find_element(By.CLASS_NAME,"anticon.anticon-right").click()343			driver.forward()344			driver.switch_to.window(driver.window_handles[0])345			sleep(1)			346	#ç©éµå¤éââé屿¾ç¤º347	elif  driver.find_elements(By.ID,"1466639248994521109"):348		print(r"ç©éµå¤éââé屿¾ç¤º")349		old_row = "None"350		while True:351			rows = driver.find_elements(By.CLASS_NAME,"ant-table-row.ant-table-row-level-0")352			row = rows[-1]353			if row == old_row:354				break355			else:356				options = row.find_elements(By.CLASS_NAME,"ant-checkbox-input")357				num = random.randint(1,len(options))358				for option in random.sample(options,num):359					option.click()360				old_row = row361	#ç©éµå¤éââåºé¨è¡äºæ¥362	if driver.find_elements(By.ID,"1466657198283608065"):363		print(r"ç©éµå¤éââåºé¨è¡äºæ¥")364		try:365			rows = driver.find_elements(By.CLASS_NAME,"ant-table-row.ant-table-row-level-0")366			for row in rows:367				options_all=row.find_elements(By.CLASS_NAME,"ant-checkbox-input")368				options_disable = row.find_elements(By.CSS_SELECTOR,("input[disabled]"))369				options = list(set(options_all)-set(options_disable))370				num = random.randint(1,len(options))371				for option in random.sample(options,num):372					option.click()373		except:374			sleep(2)375			pass376	#ç©éµå¤éââç¦ç¨ååäºæ¥377	elif  driver.find_elements(By.ID,"1466639248986132521") or driver.find_elements(By.ID,"1466639249002909710"):378		print(r"ç©éµå¤éââç¦ç¨ååäºæ¥")379		try:380			rows_all = driver.find_elements(By.CLASS_NAME,"ant-table-row.ant-table-row-level-0")381			rows_disable = driver.find_elements(By.CLASS_NAME,"ant-table-row.ant-table-row-level-0.custom-head")382			rows = list(set(rows_all)-set(rows_disable))383			for row in rows:384				options_all1=row.find_elements(By.CLASS_NAME,"ant-checkbox-input")385				options_disable1 = row.find_elements(By.CSS_SELECTOR,("input[disabled]"))386				options1 = list(set(options_all1)-set(options_disable1))387				option1 = random.choice(options1)388				if option1.is_selected():389					pass390				else:391					option1.click()392				sleep(1)393				options_all2 = row.find_elements(By.CLASS_NAME,"ant-checkbox-input")394				options2 = list(set(options_all2) - set(options_disable1))395				options2.remove(option1)396				maxnum = len(options2)397				num = random.randint(0,maxnum)398				for option in random.sample(options2,num):399					if option.is_selected():400						pass401					else:					402						option.click()403				sleep(2)	404		except:405			sleep(2)406			pass407	sleep(1)408409def read_input():410	print(r"https://answer.91question.com/91/27c6cde183c14131ba15a98d377eb918?test=1")411	cycs = int(input("请è¾å
¥éè¦å¾ªç¯ç次æ°ï¼"))412	url = str(input("请è¾å
¥éè¦æµè¯çç½åï¼"))	413	#url = "https://answer.91question.com/91/27c6cde183c14131ba15a98d377eb918?test=1"414	#cycs = int(5)415	return cycs,url416417418419if __name__ == '__main__':420	breaknum = 0421	finnum = 0422	errnum = 0423	cycs,url = read_input()424	for cyc in range(cycs):425		result = 0426		driver = get_url(url)427		while True:428			sleep(1)429			single_radio(driver)430			list_boxs(driver)431			dropdown_radio(driver)432			matrix_radio(driver)433			maxdiff_row(driver)		434			radio_page(driver)435			drag_drop(driver)436			matrix_select(driver)		437			matrix_checkbox(driver)438			if driver.find_elements(By.ID,"1466639248986132497"):439				ant_checkbox(driver,4)440			elif driver.find_elements(By.ID,"1469128264033697794"):441				ant_checkbox(driver,5)442			ant_input(driver)443			result = next_page(driver)444			if result == 1:445				breaknum += 1446				break447			elif result == 2:448				finnum += 1449				break	450			elif result == 0:451				pass452			elif result == 3:453				errnum += 1454				break		
...event_firing_webdriver.py
Source:event_firing_webdriver.py  
...90        91    def find_element(self, by=By.ID, value=None):92        return self._dispatch("find", (by, value, self._driver), "find_element", (by, value))93    94    def find_elements(self, by=By.ID, value=None):95        return self._dispatch("find", (by, value, self._driver), "find_elements", (by, value))96    97    def find_element_by_id(self, id_):98        return self.find_element(by=By.ID, value=id_)99    100    def find_elements_by_id(self, id_):101        return self.find_elements(by=By.ID, value=id_)102    103    def find_element_by_xpath(self, xpath):104        return self.find_element(by=By.XPATH, value=xpath)105    106    def find_elements_by_xpath(self, xpath):107        return self.find_elements(by=By.XPATH, value=xpath)108    109    def find_element_by_link_text(self, link_text):110        return self.find_element(by=By.LINK_TEXT, value=link_text)111    112    def find_elements_by_link_text(self, text):113        return self.find_elements(by=By.LINK_TEXT, value=text)114    115    def find_element_by_partial_link_text(self, link_text):116        return self.find_element(by=By.PARTIAL_LINK_TEXT, value=link_text)117    118    def find_elements_by_partial_link_text(self, link_text):119        return self.find_elements(by=By.PARTIAL_LINK_TEXT, value=link_text)120    121    def find_element_by_name(self, name):122        return self.find_element(by=By.NAME, value=name)123    124    def find_elements_by_name(self, name):125        return self.find_elements(by=By.NAME, value=name)126    127    def find_element_by_tag_name(self, name):128        return self.find_element(by=By.TAG_NAME, value=name)129    130    def find_elements_by_tag_name(self, name):131        return self.find_elements(by=By.TAG_NAME, value=name)132    133    def find_element_by_class_name(self, name):134        return self.find_element(by=By.CLASS_NAME, value=name)135    136    def find_elements_by_class_name(self, name):137        return self.find_elements(by=By.CLASS_NAME, value=name)138    139    def find_element_by_css_selector(self, css_selector):140        return self.find_element(by=By.CSS_SELECTOR, value=css_selector)141    142    def find_elements_by_css_selector(self, css_selector):143        return self.find_elements(by=By.CSS_SELECTOR, value=css_selector)144    145    def _dispatch(self, l_call, l_args, d_call, d_args):146        getattr(self._listener, "before_%s" % l_call)(*l_args)147        try:148            result = getattr(self._driver, d_call)(*d_args)149        except Exception as e:150            self._listener.on_exception(e, self._driver)151            raise e152        getattr(self._listener, "after_%s" % l_call)(*l_args)153        return  _wrap_elements(result, self)154    155    def _unwrap_element_args(self, args):156        if isinstance(args, EventFiringWebElement):157            return args.wrapped_element158        elif isinstance(args, tuple):159            return tuple([self._unwrap_element_args(item) for item in args])160        elif isinstance(args, list):161            return [self._unwrap_element_args(item) for item in args]162        else:163            return args164        165    def __setattr__(self, item, value):166        if item.startswith("_") or not hasattr(self._driver, item):167            object.__setattr__(self, item, value)168        else:169            try:170                object.__setattr__(self._driver, item, value)171            except Exception as e:172                self._listener.on_exception(e, self._driver)173                raise e174            175    def __getattr__(self, name):176        177        def _wrap(*args):178            try:179                result = attrib(*args)180                return _wrap_elements(result, self)181            except Exception as e:182                self._listener.on_exception(e, self._driver)183                raise e184                185        if hasattr(self._driver, name):186            try:187                attrib = getattr(self._driver, name)188                if not callable(attrib):189                    return attrib190            except Exception as e:191                self._listener.on_exception(e, self._driver)192                raise e193            return _wrap194        195        raise AttributeError(name)196    197    198class EventFiringWebElement(object):199    """"200    A wrapper around WebElement instance which supports firing events201    """202    203    def __init__(self, webelement, ef_driver):204        """205        Creates a new instance of the EventFiringWebElement206        """207        self._webelement = webelement208        self._ef_driver = ef_driver209        self._driver = ef_driver.wrapped_driver210        self._listener = ef_driver._listener211        212    @property213    def wrapped_element(self):214        """Returns the WebElement wrapped by this EventFiringWebElement instance"""215        return self._webelement216    217    def click(self):218        self._dispatch("click", (self._webelement, self._driver), "click", ())219        220    def clear(self):221        self._dispatch("change_value_of", (self._webelement, self._driver), "clear", ())222        223    def send_keys(self, *value):224        self._dispatch("change_value_of", (self._webelement, self._driver), "send_keys", value)225        226    def find_element(self, by=By.ID, value=None):227        return self._dispatch("find", (by, value, self._driver), "find_element", (by, value))228    229    def find_elements(self, by=By.ID, value=None):230        return self._dispatch("find", (by, value, self._driver), "find_elements", (by, value))231    232    def find_element_by_id(self, id_):233        return self.find_element(by=By.ID, value=id_)234    235    def find_elements_by_id(self, id_):236        return self.find_elements(by=By.ID, value=id_)237    238    def find_element_by_name(self, name):239        return self.find_element(by=By.NAME, value=name)240    241    def find_elements_by_name(self, name):242        return self.find_elements(by=By.NAME, value=name)243    244    def find_element_by_link_text(self, link_text):245        return self.find_element(by=By.LINK_TEXT, value=link_text)246    247    def find_elements_by_link_text(self, link_text):248        return self.find_elements(by=By.LINK_TEXT, value=link_text)249    250    def find_element_by_partial_link_text(self, link_text):251        return self.find_element(by=By.PARTIAL_LINK_TEXT, value=link_text)252    253    def find_elements_by_partial_link_text(self, link_text):254        return self.find_elements(by=By.PARTIAL_LINK_TEXT, value=link_text)255    256    def find_element_by_tag_name(self, name):257        return self.find_element(by=By.TAG_NAME, value=name)258    259    def find_elements_by_tag_name(self, name):260        return self.find_elements(by=By.TAG_NAME, value=name)261    262    def find_element_by_xpath(self, xpath):263        return self.find_element(by=By.XPATH, value=xpath)264    265    def find_elements_by_xpath(self, xpath):266        return self.find_elements(by=By.XPATH, value=xpath)267    268    def find_element_by_class_name(self, name):269        return self.find_element(by=By.CLASS_NAME, value=name)270    271    def find_elements_by_class_name(self, name):272        return self.find_elements(by=By.CLASS_NAME, value=name)273    274    def find_element_by_css_selector(self, css_selector):275        return self.find_element(by=By.CSS_SELECTOR, value=css_selector)276    277    def find_elements_by_css_selector(self, css_selector):278        return self.find_elements(by=By.CSS_SELECTOR, value=css_selector)279    280    def _dispatch(self, l_call, l_args, d_call, d_args):281        getattr(self._listener, "before_%s" % l_call)(*l_args)282        try:283            result = getattr(self._webelement, d_call)(*d_args)284        except Exception as e:285            self._listener.on_exception(e, self._driver)286            raise e287        getattr(self._listener, "after_%s" % l_call)(*l_args)288        return  _wrap_elements(result, self._ef_driver)289    290    def __setattr__(self, item, value):291        if item.startswith("_") or not hasattr(self._webelement, item):292            object.__setattr__(self, item, value)...Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
