How to use tag_name method of Selenium.WebDriver Package

Best Selenium code snippet using Selenium.WebDriver.tag_name

main.rake

Source:main.rake Github

copy

Full Screen

...82 driver.find_element(class: "follow-text").click83 when 284 if follow.target_postLink != nil85 driver.get(follow.target_postLink)86 wait.until {driver.find_element(tag_name: 'button').displayed?}87 driver.find_element(tag_name: 'button').click88 else89 driver.get("https://www.instagram.com/#{follow.target_username}")90 wait.until {driver.find_element(tag_name: "button").displayed?}91 puts follow_text = driver.find_element(tag_name: "button").text92 if follow_text.include?("フォロー中")93 follow.destroy94 driver.quit95 next96 end97 driver.find_element(tag_name: "button").click98 end99 end100 rescue => e101 puts e102 follow.destroy103 driver.quit104 next105 end106 line_notify = LineNotify.new("Sq7cScOUtjJ0Cqbl3C1QX7Z6aLlFDoX20qRJUBI12tS")107 if follow.target_username == nil108 options = {message: "\n#{account.profile_name}(ID:#{account.id})\n@#{follow.target_postLink}の投稿のアカウントをフォローしました。"}109 else110 options = {message: "\n#{account.profile_name}(ID:#{account.id})\n@#{follow.target_username}\nをフォローしました。"}111 end112 line_notify.send(options)113 follow.update(follow_flg:1)114 driver.quit115 end116 end117 if result < 173118 sleep(173 - result)119 end120 end121 end122 task :fav => :environment do123 require 'line_notify'124 require 'selenium-webdriver'125 require 'benchmark'126 account_ids = Fav.select(:account_id).where(fav_flg:0).distinct127 loop do128 result = Benchmark.realtime do129 Account.where(id:account_ids).each do |account|130 options = Selenium::WebDriver::Chrome::Options.new131 options.add_argument("--user-data-dir=./profile#{account.id}")132 #options.add_argument("--disable-application-cache")133 options.add_argument("--disable-gpu")134 options.add_argument("--window-size=1929,2160")135 options.add_argument("--user-agent=#{USER_AGENT}")136 options.add_argument('--start-maximized')137 options.add_argument("--disable-dev-shm-usage")138 options.add_argument("--no-sandbox")139 options.add_argument("--disable-setuid-sandbox")140 options.add_argument("--lang=ja")141 driver = Selenium::WebDriver.for :chrome, options: options142 wait = Selenium::WebDriver::Wait.new(:timeout => 5)143 fav = Fav.find_by('account_id = ? and fav_flg = ?',account.id,0)144 unless fav145 driver.quit146 next147 end148 begin149 case account.sns_type150 when 1151 driver.get(fav.target_postLink)152 begin153 wait.until {driver.find_element(class: 'js-actionFavorite').displayed?}154 rescue155 fav.destroy156 driver.quit157 next158 end159 fav_text = driver.find_element(class: 'js-actionFavorite').text160 puts fav_text161 if fav_text.include?("取り消す")162 fav.destroy163 driver.quit164 next165 end166 driver.find_element(class: 'js-actionFavorite').location_once_scrolled_into_view167 driver.find_element(class: 'js-actionFavorite').click168 when 2169 if fav.target_postLink == nil170 driver.get("https://www.instagram.com/#{fav.target_username}/")171 wait.until {driver.find_element(tag_name: 'article').displayed?}172 if driver.find_element(tag_name: 'article').text.include?("このアカウントは非公開です")173 fav.destroy174 driver.quit175 next176 end177 wait.until {driver.find_element(css: 'article div:nth-child(1) div div:nth-child(1) div:nth-child(1) a').displayed?}178 driver.find_element(css: 'article div:nth-child(1) div div:nth-child(1) div:nth-child(1) a').location_once_scrolled_into_view179 driver.find_element(css: 'article div:nth-child(1) div div:nth-child(1) div:nth-child(1) a').click180 sleep 1181 driver.execute_script('document.getElementsByClassName("glyphsSpriteHeart__outline__24__grey_9")[1].click();')182 else183 puts fav.target_postLink184 driver.navigate.to(fav.target_postLink)185 wait.until {driver.find_element(class: "glyphsSpriteHeart__outline__24__grey_9").displayed?}186 puts fav_text = driver.find_element(class: "glyphsSpriteHeart__outline__24__grey_9").attribute("aria-label")187 if fav_text.include?("取り消す")188 fav.destroy189 driver.quit190 next191 end192 puts driver.find_element(tag_name:"body").text193 driver.execute_script('document.getElementsByClassName("glyphsSpriteHeart__outline__24__grey_9")[0].click();')194 end195 end196 rescue => e197 puts e198 if fav.target_postLink == nil199 options = {message: "\n#{account.profile_name}(ID:#{account.id})\n@#{fav.target_username}の最新投稿をいいねしました。"}200 Notification.create(201 title:"いいね",content:"\n#{account.profile_name}(ID:#{account.id})\n@#{fav.target_username}の最新投稿をいいねしました。",202 notification_type:11,isRead:1,account_id:account.id,user_id:account.user_id203 )204 else205 options = {message: "\n#{account.profile_name}(ID:#{account.id})\n#{fav.target_postLink}\nをいいねしました。"}206 Notification.create(207 title:"いいね",content:"\n#{account.profile_name}(ID:#{account.id})\n#{fav.target_postLink}\nをいいねしました。",208 notification_type:11,isRead:1,account_id:account.id,user_id:account.user_id209 )210 end211 line_notify.send(options)212 fav.destroy213 driver.quit214 next215 end216 line_notify = LineNotify.new("Sq7cScOUtjJ0Cqbl3C1QX7Z6aLlFDoX20qRJUBI12tS")217 if fav.target_postLink == nil218 options = {message: "\n#{account.profile_name}(ID:#{account.id})\n@#{fav.target_username}の最新投稿をいいねしました。"}219 Notification.create(220 title:"いいね",content:"\n#{account.profile_name}(ID:#{account.id})\n@#{fav.target_username}の最新投稿をいいねしました。",221 notification_type:11,isRead:1,account_id:account.id,user_id:account.user_id222 )223 else224 options = {message: "\n#{account.profile_name}(ID:#{account.id})\n#{fav.target_postLink}\nをいいねしました。"}225 Notification.create(226 title:"いいね",content:"\n#{account.profile_name}(ID:#{account.id})\n#{fav.target_postLink}\nをいいねしました。",227 notification_type:11,isRead:1,account_id:account.id,user_id:account.user_id228 )229 end230 line_notify.send(options)231 fav.update(fav_flg:1)232 driver.quit233 end234 end235 if result < 87236 sleep(87 - result)237 end238 end239 end240 task :unfollow => :environment do241 require 'selenium-webdriver'242 account_ids = Follow.select(:account_id).where(follow_flg:1).distinct243 loop do244 result = Benchmark.realtime do245 Account.where(id:account_ids).each do |account|246 interval = UnFollowSetting.find_by(account_id:account.id).intervalDay247 checkFlg = UnFollowSetting.find_by(account_id:account.id).checkFlg248 follow = Follow.find_by('account_id = ? and follow_flg = ?',account.id,1)249 unless follow250 driver.quit251 next252 end253 if (Date.today - follow.updated_at.to_date).to_i < interval254 next255 end256 options = Selenium::WebDriver::Chrome::Options.new257 options.add_argument("--user-data-dir=./profile#{account.id}")258 #options.add_argument("--disable-application-cache")259 options.add_argument("--disable-gpu")260 options.add_argument("--window-size=1929,2160")261 options.add_argument("--user-agent=#{USER_AGENT}")262 options.add_argument('--start-maximized')263 options.add_argument("--disable-dev-shm-usage")264 options.add_argument("--no-sandbox")265 options.add_argument("--disable-setuid-sandbox")266 options.add_argument("--lang=ja")267 driver = Selenium::WebDriver.for :chrome, options: options268 wait = Selenium::WebDriver::Wait.new(:timeout => 5)269 begin270 case account.sns_type271 when 1272 when 2273 if follow.target_postLink != nil274 driver.get(follow.target_postLink)275 wait.until {driver.find_element(tag_name: 'button').displayed?}276 driver.find_element(tag_name: 'button').click277 else278 driver.get("https://www.instagram.com/#{follow.target_username}")279 wait.until {driver.find_element(tag_name: "button").displayed?}280 puts follow_text = driver.find_element(tag_name: "button").text281 if follow_text.include?("フォロー中")282 follow.destroy283 driver.quit284 next285 end286 driver.find_element(tag_name: "button").click287 end288 end289 rescue => e290 puts e291 follow.destroy292 driver.quit293 next294 end295 line_notify = LineNotify.new("Sq7cScOUtjJ0Cqbl3C1QX7Z6aLlFDoX20qRJUBI12tS")296 if follow.target_username == nil297 options = {message: "\n#{account.profile_name}(ID:#{account.id})\n#{follow.target_postLink}の投稿のアカウントをアンフォローしました。"}298 Notification.create(299 title:"アンフォロー",content:"#{follow.target_postLink}の投稿のアカウントをアンフォローしました。",300 notification_type:12,isRead:1,account_id:account.id,user_id:account.user_id301 )302 else303 options = {message: "\n#{account.profile_name}(ID:#{account.id})\n@#{follow.target_username}\nをアンフォローしました。"}304 Notification.create(305 title:"アンフォロー",content:"@#{follow.target_username}をアンフォローしました。",306 notification_type:12,isRead:1,account_id:account.id,user_id:account.user_id307 )308 end309 line_notify.send(options)310 follow.destroy311 driver.quit312 end313 end314 if result < 173315 sleep(173 - result)316 end317 end318 end319 task :profile => :environment do320 require 'selenium-webdriver'321 Account.where(sns_type:2).each do |account|322 options = Selenium::WebDriver::Chrome::Options.new323 options.add_argument("--user-data-dir=./profile#{account.id}")324 #options.add_argument("--headless")325 options.add_argument("--disable-application-cache")326 #options.add_option(:binary, "/usr/bin/google-chrome")327 options.add_argument("--user-agent=#{USER_AGENT}")328 options.add_argument('--start-maximized')329 options.add_argument("--disable-dev-shm-usage")330 options.add_argument("--no-sandbox")331 options.add_argument("--disable-setuid-sandbox")332 options.add_argument("--lang=ja")333 driver = Selenium::WebDriver.for :chrome, options: options334 wait = Selenium::WebDriver::Wait.new(:timeout => 5)335 case account.sns_type336 when 1337 driver.get("https://twitter.com/login?lang=ja")338 current = driver.current_url339 puts current340 wait.until {driver.find_element(xpath: '//*[@id="page-container"]/div/div[1]/form/fieldset/div[1]/input').displayed?}341 driver.find_element(xpath: '//*[@id="page-container"]/div/div[1]/form/fieldset/div[1]/input').send_keys(account.username)342 wait.until {driver.find_element(xpath: '//*[@id="page-container"]/div/div[1]/form/fieldset/div[2]/input').displayed?}343 driver.find_element(xpath: '//*[@id="page-container"]/div/div[1]/form/fieldset/div[2]/input').send_keys(account.pass)344 driver.find_element(:xpath, '//*[@id="page-container"]/div/div[1]/form/div[2]/button').click345 wait.until {driver.current_url != current}346 when 2347 driver.get("https://www.instagram.com/accounts/login/?hl=ja")348 current = driver.current_url349 puts current350 begin351 wait.until {driver.find_element(name: 'username').displayed?}352 driver.find_element(name: 'username').send_keys(account.username)353 wait.until {driver.find_element(name: 'password').displayed?}354 driver.find_element(name: 'password').send_keys(account.pass)355 driver.find_element(name: 'password').send_keys(:return)356 wait.until {driver.current_url != current}357 current = driver.current_url358 puts current359 rescue360 driver.quit361 next362 end363 end364 driver.navigate.to("https://www.instagram.com/")365 driver.navigate.to("https://www.instagram.com/#{account.username}")366 driver.quit367 end368 end369 task :analyze => :environment do370 require "mechanize"371 Account.all.each do |account|372 follower_count = 0373 follow_count = 0374 post_count = 0375 profile_image = ""376 case account.sns_type377 when 1378 agent = Mechanize.new379 page = agent.get("https://twitter.com/#{account.username}")380 puts profile_image = page.at(".ProfileAvatar-image").get_attribute(:src)381 puts follower_count = page.search(".ProfileNav-value")[2].get_attribute("data-count")382 puts follow_count = page.search(".ProfileNav-value")[1].get_attribute("data-count")383 puts post_count = page.search(".ProfileNav-value")[0].get_attribute("data-count")384 when 2385 agent = Mechanize.new386 page = agent.get("https://www.instagram.com/#{account.username}/")387 page.search("meta").each do |e|388 if e.get_attribute(:property) == "og:image"389 puts profile_image = e.get_attribute(:content)390 end391 if e.get_attribute(:property) == "og:description"392 data = e.get_attribute(:content).split(" ")393 puts follower_count = data[0].gsub(/[^\d]/, "").to_i394 puts follow_count = data[2].gsub(/[^\d]/, "").to_i395 puts post_count = data[4].gsub(/[^\d]/, "").to_i396 end397 end398 end399 Analyze.create(400 follow_count:follow_count,follower_count:follower_count,post_count:post_count,401 profile_image:profile_image,account_id:account.id402 )403 end404 end405 task :reply => :environment do406 require 'selenium-webdriver'407 options = Selenium::WebDriver::Chrome::Options.new408 #options.headless!409 #options.add_option(:binary, "/usr/bin/google-chrome")410 options.add_argument("--user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36")411 options.add_argument('--start-maximized')412 options.add_argument("--disable-dev-shm-usage")413 options.add_argument("--no-sandbox")414 options.add_argument("--disable-setuid-sandbox")415 driver = Selenium::WebDriver.for :chrome, options: options416 wait = Selenium::WebDriver::Wait.new(:timeout => 5)417 driver.get("https://www.instagram.com/accounts/login")418 wait.until {driver.find_element(name: 'username').displayed?}419 driver.find_element(name: 'username').send_keys("sato__hideki")420 wait.until {driver.find_element(name: 'password').displayed?}421 driver.find_element(name: 'password').send_keys("oneokrock")422 wait.until {driver.find_elements(tag_name: "button")[1].displayed?}423 driver.find_elements(tag_name: "button")[1].click424 sleep(2)425 driver.navigate.to("https://www.instagram.com/p/BqyP0yFnh_Th2O7MkknO6JxcxAc_ipRqz5qQOk0/")426 wait.until {driver.find_element(tag_name: "textarea").displayed?}427 driver.find_element(tag_name: "textarea").click428 driver.find_element(tag_name: "textarea").send_keys("自動コメントテスト")429 driver.find_element(tag_name: "textarea").send_keys(:enter)430 sleep(2)431 end432 task :seleniumfix => :environment do433 require 'selenium-webdriver'434 caps = Selenium::WebDriver::Remote::Capabilities.chrome(435 "chromeOptions" => {436 binary: "/usr/bin/google-chrome",437 args: ["--window-size=1920,1080","--start-maximized","--headless",'--no-sandbox','--disable-dev-shm-usage'438 ]439 }440 )441 driver = Selenium::WebDriver.for :chrome, desired_capabilities: caps442 driver.quit443 end...

Full Screen

Full Screen

helpers.rb

Source:helpers.rb Github

copy

Full Screen

...6 @driver ||= page.driver.browser7 end8 9 def bobcat_header_spans10 header.native.find_elements(:tag_name, "span")11 end12 13 # Navigate to the current @view and @tab14 def navigate_to_tab()15 driver.navigate.to "#{@search_url}?vid=#{@view}"16 wait = Selenium::WebDriver::Wait.new(:timeout => 20)17 wait.until {18 begin19 tabs.find_element(:css, "ul li##{@tab}")20 true21 rescue Selenium::WebDriver::Error::NoSuchElementError => e22 false23 end24 }25 tab = driver.find_element(:css, "div#tabs ul li##{@tab}")26 tab.find_element(:tag_name, "a").click unless tab[:class].eql?("selected")27 wait_for_search_field28 end29 30 # Click the eshelf link in the sidebar.31 def click_eshelf_link()32 eshelf_link.click33 wait_for_eshelf34 end35 36 # Submit a search for the given search term.37 def submit_search(search_term)38 fill_in 'search_field', :with => search_term39 click_button 'goButton'40 wait_for_search search_term41 end42 43 # Set media type44 def set_media_type(media_type_value)45 media_type = Selenium::WebDriver::Support::Select.new(driver.find_element(:id, "exlidInput_mediaType_1"))46 media_type.select_by(:value, media_type_value)47 end48 49 # Set precision operator50 def set_precision(precision_value)51 precision = Selenium::WebDriver::Support::Select.new(driver.find_element(:id, "exlidInput_precisionOperator_1"))52 precision.select_by(:value, precision_value)53 end54 55 # Set scope 156 def set_scope1(scope1_value)57 scope1 = Selenium::WebDriver::Support::Select.new(driver.find_element(:id, "exlidInput_scope_1"))58 scope1.select_by(:value, scope1_value)59 end60 61 # Set scope 262 def set_scope2(scope2_value)63 scope2 = Selenium::WebDriver::Support::Select.new(driver.find_element(:name, "scp.scps"))64 scope2.select_by(:value, scope2_value)65 end66 67 # Click the details link. Defaults to first link68 def click_details_link(index=0)69 title = record_title(index)70 details_link(index).click71 wait_for_details(title)72 end73 74 # Click the add to eshelf checkbox. Defaults to first record on brief screen.75 def click_add_to_eshelf(index=0)76 add_to_eshelves = driver.find_elements(:css, ".save_record input.tsetse_generated")77 add_to_eshelves[index].click78 end79 80 # Click the send/share button. Defaults to first record on brief screen.81 def click_send_share(index=0)82 send_shares = driver.find_elements :xpath, xpaths[:send_share]83 send_shares[index].click84 end85 86 # Click the email link. Defaults to first record on brief screen.87 def click_email_link(index=0)88 email_links = driver.find_elements :xpath, xpaths[:email_link]89 email_links[index].click90 wait_for_email_modal91 end92 93 # Send an email to the given email address.94 def send_email(email_address)95 subject = driver.find_element(:css, '.ui-dialog .ui-dialog-content form input#subject')96 subject.send_keys " - Jenkins probably sent this to you."97 to = driver.find_element(:css, '.ui-dialog .ui-dialog-content form input#sendTo')98 to.send_keys email_address99 to.submit100 wait_for_email_send101 end102 103 # Get the email confirmation message104 def email_confirmation()105 driver.find_element(:css, '.ui-dialog .ui-dialog-content div')106 end107 108 # Close the email modal window109 def close_email_modal()110 driver.find_element(:css, '.ui-dialog .ui-dialog-titlebar .ui-icon-closethick').click111 end112 113 # Click the print link. Defaults to first record on brief screen.114 # Switches to the print window.115 def click_print_link(index=0)116 print_links = driver.find_elements :xpath, xpaths[:print_link]117 print_links[index].click118 driver.switch_to.window(driver.window_handles.last)119 end120 121 # Close the print window122 def close_print_window()123 # Close the window124 driver.close125 # Switch back to original window.126 driver.switch_to.window(driver.window_handles.first)127 end128 129 # Return the array of sidebar boxes130 def sidebar_boxes()131 wait_for_sidebar132 sidebar.find_elements(:class, "box")133 end134 135 # Return the specified sidebar box. Default to the first box.136 def sidebar_box(index=0)137 sidebar_boxes[index]138 end139 140 # Return the specified sidebar box identified by the specified id141 def sidebar_box_by_id(id)142 wait_for_sidebar143 sidebar.find_element(:id, id)144 end145 146 # Return the account box147 def sidebar_account_box()148 sidebar_box_by_id("account")149 end150 151 # Return the help box152 def sidebar_help_box()153 sidebar_box_by_id("help")154 end155 156 # Return the additional options box157 def sidebar_additional_options_box()158 sidebar_box_by_id("additional_options")159 end160 161 # Return the array of list items for the sidebar box identified by the specified index. Default to first box.162 def sidebar_box_items(index=0)163 sidebar_box(index).find_elements(:tag_name, "li")164 end165 166 # Return the array of list items for the sidebar box identified by the specified id167 def sidebar_box_items_by_id(id)168 sidebar_box_by_id(id).find_elements(:tag_name, "li")169 end170 171 # Return the array of account box items172 def sidebar_account_box_items()173 sidebar_box_items_by_id("account")174 end175 176 # Return the array of help box items177 def sidebar_help_box_items()178 sidebar_box_items_by_id("help")179 end180 181 # Return the array of additional options box items182 def sidebar_additional_options_box_items()183 sidebar_box_items_by_id("additional_options")184 end185 186 # Return the eshelf link187 def eshelf_link()188 eshelf_index = (@view.eql?("NYSID")) ? (driver.find_elements(:css, "a.logout").empty? ? 2 : 1 ) : 0189 sidebar_account_box_items[eshelf_index].find_element(:tag_name, "a")190 end191 192 # Return the search_form element193 def search_form()194 search_container.find_element(:name, "searchForm")195 end196 197 # Return the array of facet boxes198 def facets_boxes()199 facets.all(".box")200 end201 202 # Return the specified facet box. Default to the first box.203 def facets_box(index=0)204 facets_boxes[index]205 end206 207 # Return the array of pagination elements208 def pagination_elements()209 results_list.all(".pagination")210 end211 212 # Return the results list element213 def results_list()214 page.find(:css, ".results")215 rescue216 return nil217 end218 219 def wait_for_results_list()220 wait = Selenium::WebDriver::Wait.new(:timeout => 10)221 assert_nothing_raised(Selenium::WebDriver::Error::TimeOutError, "Error waiting for search for logout #{driver.current_url} view #{@view} and tab #{@tab}.") {222 wait.until {223 begin224 results_list225 true226 rescue Selenium::WebDriver::Error::NoSuchElementError => e227 false228 end229 }230 }231 end232 233 # Return the array of results list items234 def results_list_items()235 results_list.all(".result")236 end237 238 # Return the specified results list item. Default to the first item239 def results_list_item(index=0)240 results_list_items[index]241 end242 243 # Return an array of Primo add to eshelf checkboxes244 def add_to_eshelf_checkboxes()245 driver.find_elements(:css, ".save_record input.tsetse_generated")246 end247 248 # Return the specified Primo add to eshelf checkbox. Default to the first checkbox.249 def add_to_eshelf_checkbox(index=0)250 add_to_eshelf_checkboxes[index]251 end252 253 # Return an array of Primo details link elements254 def details_links()255 results_list.find_elements(:css, ".fulldetails a")256 end257 258 # Return the specified Primo details link. Default to the first checkbox.259 def details_link(index=0)260 details_links[index]261 end262 263 # Return the list of Primo title strings264 def record_titles()265 titles = []266 driver.find_elements(:css, ".entree h2.title").each do |title|267 titles << title.text268 end269 return titles270 end271 272 # Return the specified Primo title string. Default to the first title.273 def record_title(index=0)274 record_titles[index]275 end276 277 # Return the list of e-shelf title strings278 def eshelf_titles()279 titles = []280 driver.find_elements(:css, '.entree h2.title').each do |title|281 titles << title.text282 end283 return titles284 end285 286 # Return the specified e-shelf title string. Default to the first title.287 def eshelf_title(index=0)288 eshelf_titles[index]289 end290 291 def wait_for_sidebar()292 wait = Selenium::WebDriver::Wait.new(:timeout => 10)293 assert_nothing_raised(Selenium::WebDriver::Error::TimeOutError, "Error waiting for search field for url #{driver.current_url} view #{@view} and tab #{@tab}.") {294 wait.until {295 begin296 sidebar297 true298 rescue Selenium::WebDriver::Error::NoSuchElementError => e299 false300 end301 }302 }303 end304 305 # Wait for the search field to display306 def wait_for_search_field()307 wait = Selenium::WebDriver::Wait.new(:timeout => 10)308 wait.until {309 begin310 search_field311 true312 rescue Selenium::WebDriver::Error::NoSuchElementError => e313 false314 end315 }316 end317 318 # Wait for the search for the 'search_term' to complete319 def wait_for_search(search_term)320 wait = Selenium::WebDriver::Wait.new(:timeout => 10)321 wait.until {322 begin323 search_field324 driver.title.eql?("BobCat - #{search_term}")325 rescue Selenium::WebDriver::Error::NoSuchElementError => e326 false327 end328 }329 end330 331 # Wait for the full details page for the given 'title' to render332 def wait_for_details(title)333 wait = Selenium::WebDriver::Wait.new(:timeout => 10)334 assert_nothing_raised(Selenium::WebDriver::Error::TimeOutError, "Error waiting for details for url #{driver.current_url} view #{@view} and tab #{@tab}.") {335 wait.until {336 driver.title.eql?("BobCat - #{title}")337 }338 }339 end340 341 # Wait for the email modal to display. Generally Primo::Helpers#click_email_link should be used instead342 def wait_for_email_modal()343 wait = Selenium::WebDriver::Wait.new(:timeout => 10)344 assert_nothing_raised(Selenium::WebDriver::Error::TimeOutError, "Error waiting for email modal for url #{driver.current_url} view #{@view} and tab #{@tab}.") {345 wait.until {346 begin347 driver.find_element(:css, ".ui-dialog .ui-dialog-content form#mailFormId")348 true349 rescue Selenium::WebDriver::Error::NoSuchElementError => e350 false351 end352 }353 }354 end355 356 # Wait for the email to send. Generally Primo::Helpers#send_email should be used instead357 def wait_for_email_send()358 wait = Selenium::WebDriver::Wait.new(:timeout => 10)359 assert_nothing_raised(Selenium::WebDriver::Error::TimeOutError, "Error waiting for email to send for url #{driver.current_url} view #{@view} and tab #{@tab}.") {360 wait.until {361 begin362 email_confirmation363 true364 rescue Selenium::WebDriver::Error::NoSuchElementError => e365 false366 end367 }368 }369 end370 371 # Wait to add to the eshelf. Generally Primo::Helpers#add_to_eshelf should be used instead372 def wait_for_add_to_eshelf(index=0)373 wait = Selenium::WebDriver::Wait.new(:timeout => 10)374 assert_nothing_raised(Selenium::WebDriver::Error::TimeOutError, "Error waiting to add to eshelf for url #{driver.current_url} view #{@view} and tab #{@tab}.") {375 wait.until {376 wait = Selenium::WebDriver::Wait.new(:timeout => 10)377 wait.until { 378 (not driver.find_elements(:css => ".save_record label.tsetse_generated")[index].text.match("^In").nil?)379 }380 }381 }382 end383 384 # Wait to add to the eshelf. Generally Primo::Helpers#add_to_eshelf should be used instead385 def wait_for_uncheck_add_to_eshelf(index=0)386 wait = Selenium::WebDriver::Wait.new(:timeout => 10)387 assert_nothing_raised(Selenium::WebDriver::Error::TimeOutError, "Error waiting to add to eshelf for url #{driver.current_url} view #{@view} and tab #{@tab}.") {388 wait.until {389 wait = Selenium::WebDriver::Wait.new(:timeout => 10)390 wait.until { 391 (not driver.find_elements(:css => ".save_record label.tsetse_generated")[index].text.match("^Add").nil?)392 }393 }394 }395 end396 397 # Wait for the eshelf to render. Generally Primo::Helpers#click_eshelf_link should be used instead398 def wait_for_eshelf()399 wait = Selenium::WebDriver::Wait.new(:timeout => 10)400 assert_nothing_raised(Selenium::WebDriver::Error::TimeOutError, "Error waiting for eshelf for url #{driver.current_url} view #{@view} and tab #{@tab}.") {401 wait.until {402 driver.find_element(:css, "h1").text == "e-Shelf"403 }404 }405 end406 407 # Wait for pds to render. Generally Primo::Helpers#login should be used instead408 def wait_for_pds()409 wait = Selenium::WebDriver::Wait.new(:timeout => 10)410 assert_nothing_raised(Selenium::WebDriver::Error::TimeOutError, "Error waiting for pds for url #{driver.current_url} view #{@view} and tab #{@tab}.") {411 wait.until {412 driver.title.eql?("BobCat")413 }414 }415 end416 417 # Wait for shibboleth to render.418 def wait_for_shibboleth_button()419 wait = Selenium::WebDriver::Wait.new(:timeout => 10)420 assert_nothing_raised(Selenium::WebDriver::Error::TimeOutError, "Error waiting for pds for url #{driver.current_url} view #{@view} and tab #{@tab}.") {421 wait.until {422 begin423 shibboleth_button424 true425 rescue Selenium::WebDriver::Error::NoSuchElementError => e426 false427 end428 }429 }430 end431 432 # Wait for shibboleth form to render. 433 def wait_for_shibboleth_form()434 wait = Selenium::WebDriver::Wait.new(:timeout => 10)435 assert_nothing_raised(Selenium::WebDriver::Error::TimeOutError, "Error waiting for pds for url #{driver.current_url} view #{@view} and tab #{@tab}.") {436 wait.until {437 begin438 shibboleth_form439 true440 rescue Selenium::WebDriver::Error::NoSuchElementError => e441 false442 end443 }444 }445 end446 447 # Wait for login to process. Generally Primo::Helpers#login should be used instead448 def wait_for_login()449 wait = Selenium::WebDriver::Wait.new(:timeout => 10)450 assert_nothing_raised(Selenium::WebDriver::Error::TimeOutError, "Error waiting for login for url #{driver.current_url} view #{@view} and tab #{@tab}.") {451 wait.until {452 begin453 logout_element454 true455 rescue Selenium::WebDriver::Error::NoSuchElementError => e456 false457 end458 }459 }460 end461 462 # Wait for logout to process. Generally Primo::Helpers#logout should be used instead463 def wait_for_logout()464 wait = Selenium::WebDriver::Wait.new(:timeout => 10)465 assert_nothing_raised(Selenium::WebDriver::Error::TimeOutError, "Error waiting for search for logout #{driver.current_url} view #{@view} and tab #{@tab}.") {466 wait.until {467 begin468 driver.find_element(:css, ".logout > h1")469 true470 rescue Selenium::WebDriver::Error::NoSuchElementError => e471 false472 end473 }474 }475 end476 477 private478 def sort_by(sort_value)479 sort_select = Selenium::WebDriver::Support::Select.new(driver.find_element(:id, "srt"))480 sort_select.select_by(:value, sort_value)481 end482 483 # def header?()484 # # Is the header div present?485 # assert_equal("div", header.tag_name.downcase, "Tag name of header element is not 'div' for view #{@view} and tab #{@tab}.")486 # bobcat_spans = header.find_elements(:tag_name, "span")487 # assert_equal(2, bobcat_spans.size(), "Header spans return an unexpected size for view #{@view} and tab #{@tab}.")488 # bobcat_spans.each do |span|489 # # The header spans are hidden490 # assert_equal("", span.text, "Header span is not hidden for view #{@view} and tab #{@tab}.")491 # end492 # end493 # 494 # def nav1?()495 # # Is the nav1 div present?496 # assert_equal("div", nav1.tag_name.downcase, "Tag name of nav1 element is not 'div' for view #{@view} and tab #{@tab}.")497 # assert_equal("ul", nav1.find_element(:class, "floatLeft").tag_name.downcase, "Tag name of left nav1 list element is not 'ul' for view #{@view} and tab #{@tab}.")498 # assert_equal("ul", nav1.find_element(:class, "floatRight").tag_name.downcase, "Tag name of right nav1 list element is not 'ul' for view #{@view} and tab #{@tab}.")499 # end500 # 501 # def sidebar?()502 # # Is the sidebar div present?503 # assert_equal("div", sidebar.tag_name.downcase, "Tag name of sidebar element is not 'div' for view #{@view} and tab #{@tab}.")504 # assert((not sidebar_boxes.empty?), "Sidebar boxes are empty for view #{@view} and tab #{@tab}.")505 # end506 # 507 # def search?()508 # # Is the search_container div present?509 # assert_equal("div", search_container.tag_name.downcase, "Tag name of search container element is not 'div' for view #{@view} and tab #{@tab}.")510 # tabs?511 # assert_equal("form", search_form.tag_name.downcase, "Tag name of search form element is not 'form' for view #{@view} and tab #{@tab}.")512 # end513 # 514 # def tabs?()515 # assert_equal("div", tabs.tag_name.downcase, "Tag name of tabs element is not 'div' for view #{@view} and tab #{@tab}.")516 # assert((not tabs.find_elements(:tag_name, "li").empty?), "Tabs are empty for view #{@view} and tab #{@tab}.")517 # end518 # 519 # def footer?()520 # # Is the footer div present?521 # assert_equal("div", footer.tag_name.downcase, "Tag name of footer element is not 'div' for view #{@view} and tab #{@tab}.")522 # assert_not_nil(footer.text.match("Powered by Ex Libris Primo"), "Footer text is unexpected for view #{@view} and tab #{@tab}.")523 # end524 end525 end...

Full Screen

Full Screen

jobs_controller.rb

Source:jobs_controller.rb Github

copy

Full Screen

...150 container.map{|e| e.location_once_scrolled_into_view}151 lis.each_with_index do |e, i|152 job = Hash.new153 begin154 x = e.find_elements(tag_name: 'h3')[0].text155 rescue156 x = ''157 end158 job[:position]= x159 begin160 x = e.find_elements(tag_name: 'h4')[0].text161 rescue162 x = ''163 end164 job[:company]= x165 begin166 x = e.find_elements(css: '.job-card-search__company-name-link')[0].attribute('href').split('?eBP=')[0]167 rescue168 x = ''169 end170 job[:company_url]= x171 begin172 x = e.find_elements(tag_name: 'h5')[0].text[13..-1]173 rescue174 x = ''175 end176 job[:location]= x177 begin178 x = e.find_elements(tag_name: 'p')[0].text179 rescue180 x = ''181 end182 job[:description]= x183 begin184 x = e.find_elements(tag_name: 'a')[0].attribute('href').split('?eBP=')[0]185 rescue186 x = ''187 end188 job[:url]= x189 begin190 x = e.find_elements(css: '.job-card-search__easy-apply-text')[0].text == 'Easy Apply'191 rescue192 x = false193 end194 job[:easy]= x195 jobs.push(job) if job[:position] != 'See jobs where you are a top applicant'196 end197 @driver.execute_script('window.scrollTo(0, document.body.scrollHeight)')198 sleep(1)199 next_btn = @driver.find_elements(css: '.next')[0]200 begin201 next_btn.click()202 rescue203 break204 end205 sleep(1)206 wait = Selenium::WebDriver::Wait.new(:timeout => 30)207 end208 return jobs209 end210 def fetchDescriptions(cart)211 urls = cart.keys.map{|key| cart[key][:url]}212 urls.each_with_index do |link, i|213 @driver.navigate.to link214 wait = Selenium::WebDriver::Wait.new(:timeout => 30)215 begin216 expired = @driver.find_element(css: '.jobs-details-top-card__expired-job')217 if expired218 Job.find(cart[i.to_s][:job_id]).destroy219 end220 rescue221 view_more = @driver.find_elements(css: '.view-more-icon')[0]222 begin223 view_more.click()224 sleep(1)225 rescue226 end227 sleep(1)228 desc_container = @driver.find_elements(css: '#job-details *')229 # check to see if odd formatting is cause all text in one div (ember or some other linkedin markup)230 desc_container = [@driver.find_element(css: '#job-details')] if @driver.find_element(css: '#job-details').text.length > 100231 desc = []232 desc_container.each do |e|233 begin234 desc.push(e.text)235 rescue236 desc.push("")237 end238 end239 description = desc.join(' ').gsub(/[^A-Za-z ]/, ' ').gsub(/\s+/, ' ').downcase240 if description.length > 200241 cart[i.to_s][:description] = description242 Job.find(cart[i.to_s][:job_id]).update({description: description})243 else244 cart[i.to_s][:description] = Job.find(cart[i.to_s][:job_id])[:description]245 end246 end247 end248 return cart249 end250 def applyToJob(data, resume)251 number = User.find(current_user.id).phone252 result = data.map.with_index do |el, i|253 @driver.navigate.to el[1].url254 wait = Selenium::WebDriver::Wait.new(:timeout => 30)255 sleep(2)256 apply_btn = @driver.find_elements(css: '.js-apply-button')[0]257 apply_btn.click()258 wait = Selenium::WebDriver::Wait.new(:timeout => 30)259 phone = @driver.find_element(id: 'apply-form-phone-input')260 phone.send_keys number261 upload = @driver.find_element(id: 'file-browse-input')262 upload.send_keys resume263 @driver.find_elements(css: '.jobs-apply-form__follow-company-label')[0].click()264 wait = Selenium::WebDriver::Wait.new(:timeout => 30)265 @application = Application.find(el[0].id)266 @application.update({status: "sent"})267 el[0] = @application268 el269 end270 return result271 end272end273def linkedin_login(username, password, driver)274 if driver == '0'275 options = Selenium::WebDriver::Chrome::Options.new276 chrome_bin_path = ENV['GOOGLE_CHROME_SHIM']277 options.binary = chrome_bin_path if chrome_bin_path # only use custom path on heroku278 driver = Selenium::WebDriver.for :chrome279 else280 options = Selenium::WebDriver::Chrome::Options.new281 driver = Selenium::WebDriver.for(:remote, :desired_capabilities => {session_id: driver})282 end283 driver.navigate.to 'https://www.linkedin.com/'284 wait = Selenium::WebDriver::Wait.new(:timeout => 30)285 element = driver.find_element(id: 'login-email')286 element.send_keys username287 element = driver.find_element(id: 'login-password')288 element.send_keys password289 element = driver.find_element(id: 'login-submit')290 element.click291 wait = Selenium::WebDriver::Wait.new(:timeout => 30)292 status = (driver.current_url[0, 29] == 'https://www.linkedin.com/feed')293 return [driver.save_screenshot('screenshot.png'), driver, status]294end295def scrape(data)296 # chrome_bin = ENV.fetch('GOOGLE_CHROME_SHIM', nil)297 # chrome_opts = chrome_bin ? { 'chromeOptions' => { 'binary' => chrome_bin } } : {}298 # options = Selenium::WebDriver::Chrome::Options.new299 # options.add_argument('chromeOptions' => { 'binary' => '/usr/bin/google-chrome' })300 # chrome_bin_path = ENV.fetch('GOOGLE_CHROME_SHIM', '~/usr/bin/google-chrome')301 # chrome_bin_path = '/bin/google-chrome-stable'302 # chrome_bin_path = '/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome'303 # debugger304 # chromedriver_path = File.join(File.absolute_path('../..', File.dirname(__FILE__)),'browsers','chromedriver.exe')305 # Selenium::WebDriver::Chrome.driver_path = chromedriver_path306 # driver = Selenium::WebDriver.for :chrome, options: options307 # driver.navigate.to 'https://www.linkedin.com/'308 # user_name = 'shoytempus@gmail.com'309 # password = 'starwars1'310 #311 # wait = Selenium::WebDriver::Wait.new(:timeout => 60)312 #313 #314 # element = driver.find_element(id: 'login-email')315 # element.send_keys user_name316 #317 # element = driver.find_element(id: 'login-password')318 # element.send_keys password319 #320 # element = driver.find_element(id: 'login-submit')321 # element.click322 #323 # wait = Selenium::WebDriver::Wait.new(:timeout => 30)324 # puts driver.current_url325 # options = Selenium::WebDriver::Chrome::Options.new326 # chrome_bin_path = ENV['GOOGLE_CHROME_SHIM']327 # options.binary = chrome_bin_path if chrome_bin_path # only use custom path on heroku328 driver = Selenium::WebDriver.for :chrome329 driver.navigate.to 'https://www.linkedin.com/'330 x = driver.save_screenshot('resumeasy.png')331 # debugger332 while driver.current_url[0, 29] != 'https://www.linkedin.com/feed'333 sleep(1)334 end335 wait = Selenium::WebDriver::Wait.new(:timeout => 60)336 jobs = []337 page = 0338 driver.navigate.to 'https://www.linkedin.com/jobs/search/?keywords=#{data[:position]}&location=#{data[:location]}'339 wait = Selenium::WebDriver::Wait.new(:timeout => 30)340 while true341 page += 1342 container = wait.until { driver.find_elements(css: '.card-list > li') }343 lis = container.dup344 container.map{|e| e.location_once_scrolled_into_view}345 lis.each_with_index do |e, i|346 job = Hash.new347 begin348 x = e.find_elements(tag_name: 'h3')[0].text349 rescue350 x = ''351 end352 job[:position]= x353 begin354 x = e.find_elements(tag_name: 'h4')[0].text355 rescue356 x = ''357 end358 job[:company]= x359 begin360 x = e.find_elements(css: '.job-card-search__company-name-link')[0].attribute('href').split('?eBP=')[0]361 rescue362 x = ''363 end364 job[:company_url]= x365 begin366 x = e.find_elements(tag_name: 'h5')[0].text[13..-1]367 rescue368 x = ''369 end370 job[:location]= x371 begin372 x = e.find_elements(tag_name: 'p')[0].text373 rescue374 x = ''375 end376 job[:description]= x377 begin378 x = e.find_elements(tag_name: 'a')[0].attribute('href').split('?eBP=')[0]379 rescue380 x = ''381 end382 job[:url]= x383 begin384 x = e.find_elements(css: '.job-card-search__easy-apply-text')[0].text == 'Easy Apply'385 rescue386 x = false387 end388 job[:easy]= x389 jobs.push(job) if job[:position] != 'See jobs where you are a top applicant'390 end391 driver.execute_script('window.scrollTo(0, document.body.scrollHeight)')392 sleep(1)...

Full Screen

Full Screen

vamp_spec.rb

Source:vamp_spec.rb Github

copy

Full Screen

...19 driver.navigate.to url20 wait.until { driver.find_elements(:xpath, "//div[@class='catogory']") }21 driver22 .find_element(:css, "ul.sidebar-nav")23 .find_elements(:tag_name, "li")24 .select { |i| i.attribute("class") != 'has-sub-menu' }25 .select { |i| i.attribute("class") != 'sub-menu-item' }26 .select { |i| i.text.downcase == 'blueprints' }27 .each { |i|28 i.find_element(:tag_name, "a").click()29 if do_screenshots30 driver.save_screenshot("screen_" + c.to_s + ".png")31 c = c + 132 end33 button = driver34 .find_elements(:xpath, "//div[@class='row content-header']//button")35 .select { |j| j.text == 'Docker Compose' }36 .first37 button.click()38 sleep 139 if do_screenshots40 driver.save_screenshot("screen_" + c.to_s + ".png")41 c = c + 142 end43 expect(driver.find_element(:xpath, "//div[@class='modal-content']").displayed?).to eq(true)44 }45 button = driver46 .find_elements(:xpath, "//div[@class='modal-content']//button")47 .select { |j| j.text == 'Cancel' }48 .first49 button.click()50 if do_screenshots51 driver.save_screenshot("screen_" + c.to_s + ".png")52 c = c + 153 end54 button = driver55 .find_elements(:xpath, "//div[@class='row content-header']//button")56 .select { |j| j.text == 'Add' }57 .first58 if do_screenshots59 driver.save_screenshot("screen_" + c.to_s + ".png")60 c = c + 161 end62 expect(button.displayed?).to eq(true)63 driver.quit64 end65end66RSpec.describe "basic checks on top menu items" do67 it "68 - header text should be the equal to a button text69 - editor should be displayed70 - editor should be closed71 " do72 wait = Selenium::WebDriver::Wait.new(timeout: 15)73 driver = Selenium::WebDriver.for driver_name, options: driver_options74 driver.manage.window.size = Selenium::WebDriver::Dimension.new(1920, 1080)75 driver.navigate.to url76 wait.until { driver.find_elements(:xpath, "//div[@class='catogory']") }77 driver78 .find_element(:css, "ul.sidebar-nav")79 .find_elements(:tag_name, "li")80 .select { |i| i.attribute("class") != 'has-sub-menu' }81 .select { |i| i.attribute("class") != 'sub-menu-item' }82 .select { |i| i.text.downcase != 'collapse menu' }83 .each { |i|84 i.click()85 wait.until { driver.find_element(:css, "div.header-content") }86 if do_screenshots87 driver.save_screenshot("screen_" + c.to_s + ".png")88 c = c + 189 end90 expect(driver.find_element(:css, "div.header-content").text.downcase).to eq(i.text.downcase)91 expect(driver.current_url).to eq(url.downcase + i.attribute("href"))92 button = driver93 .find_elements(:xpath, "//div[@class='row content-header']//button")94 .select { |j| j.text == 'Add' }95 .first96 next_url = driver.current_url + "/" + button.text.downcase97 button.click()98 wait.until { driver.find_elements(:xpath, "//div[@class='editor-buttons clearfix']//button") }99 if do_screenshots100 driver.save_screenshot("screen_" + c.to_s + ".png")101 c = c + 1102 end103 expect(driver.find_element(:xpath, "//div[@id='editor']").displayed?).to eq(true)104 expect(driver.current_url).to eq(next_url)105 button = driver106 .find_elements(:xpath, "//div[@class='editor-buttons clearfix']//button")107 .first108 next_url = driver.current_url.split("/")[0..-2].join("/")109 button.click()110 wait.until { driver.find_elements(:xpath, "//div[@class='row content-header']//button") }111 if do_screenshots112 driver.save_screenshot("screen_" + c.to_s + ".png")113 c = c + 1114 end115 button = driver116 .find_elements(:xpath, "//div[@class='row content-header']//button")117 .select { |j| j.text == 'Add' }118 .first119 if do_screenshots120 driver.save_screenshot("screen_" + c.to_s + ".png")121 c = c + 1122 end123 expect(button.displayed?).to eq(true)124 expect(driver.current_url).to eq(next_url)125 }126 driver.quit127 end128end129RSpec.describe "basic checks on sub menu items" do130 it "- header text should be the equal to a button text" do131 wait = Selenium::WebDriver::Wait.new(timeout: 15)132 driver = Selenium::WebDriver.for driver_name, options: driver_options133 driver.manage.window.size = Selenium::WebDriver::Dimension.new(1920, 1080)134 driver.navigate.to url135 wait.until { driver.find_elements(:xpath, "//div[@class='catogory']") }136 driver137 .find_elements(:xpath, "//a[@class='btn-link collapse-btn']")138 .first139 .click()140 wait.until { driver.find_elements(:xpath, "//span[@class='icon-label hidden-xs']") }141 driver142 .find_element(:css, "ul.sidebar-nav")143 .find_elements(:xpath, "//li[@class='has-sub-menu']")144 .select{ |i| i.attribute("href") == nil }145 .each { |i|146 i.find_element(:tag_name, "a").click()147 wait.until { driver.find_elements(:xpath, "//a[@class='capitalize']") }148 if do_screenshots149 driver.save_screenshot("screen_" + c.to_s + ".png")150 c = c + 1151 end152 expect(driver.find_element(:css, "ul.sub-menu").displayed?).to eq(true)153 break154 }155 driver156 .find_element(:css, "ul.sidebar-nav")157 .find_elements(:xpath, "//li[@class='sub-menu-item']")158 .each { |i|159 i.click()160 wait.until { driver.find_elements(:xpath, "//div[@class='container-fluid main-view']") }161 if do_screenshots162 driver.save_screenshot("screen_" + c.to_s + ".png")163 c = c + 1164 end165 expect(driver.find_element(:css, "div.header-content").text.downcase).to eq(i.text.downcase)166 expect(driver.current_url).to eq(url.downcase + i.attribute("href"))167 }168 driver.quit169 end170end171RSpec.describe "test each tab in backend configuration" do172 it "- tab content should be displayed" do173 wait = Selenium::WebDriver::Wait.new(timeout: 15)174 driver = Selenium::WebDriver.for driver_name, options: driver_options175 driver.manage.window.size = Selenium::WebDriver::Dimension.new(1920, 1080)176 driver.navigate.to url177 wait.until { driver.find_elements(:xpath, "//div[@class='catogory']") }178 driver179 .find_elements(:xpath, "//a[@class='btn-link collapse-btn']")180 .first181 .click()182 wait.until { driver.find_elements(:xpath, "//span[@class='icon-label hidden-xs']") }183 driver184 .find_element(:css, "ul.sidebar-nav")185 .find_elements(:xpath, "//li[@class='has-sub-menu']")186 .select{ |i| i.attribute("href") == nil }187 .each { |i|188 i.find_element(:tag_name, "a").click()189 if do_screenshots190 driver.save_screenshot("screen_" + c.to_s + ".png")191 c = c + 1192 end193 expect(driver.find_element(:css, "ul.sub-menu").displayed?).to eq(true)194 }195 driver196 .find_element(:css, "ul.sidebar-nav")197 .find_elements(:xpath, "//li[@class='sub-menu-item']")198 .select { |i| i.text.downcase == 'backend configuration' }199 .each { |i|200 i.click()201 wait.until { driver.find_element(:css, "div.header-content") }202 if do_screenshots203 driver.save_screenshot("screen_" + c.to_s + ".png")204 c = c + 1205 end206 driver207 .find_elements(:xpath, "//ul[@class='nav nav-tabs']//li")208 .each { |j|209 j.click()210 wait.until { driver.find_elements(:xpath, "//dev[@class='nav nav-tabs']//li[@class='active']") }211 if do_screenshots212 driver.save_screenshot("screen_" + c.to_s + ".png")213 c = c + 1214 end215 expect(driver.find_element(:css, "div.tab-content").displayed?).to eq(true)216 }217 }218 driver.quit219 end220end221RSpec.describe "test each tab in vga configuration" do222 it "- tab content should be displayed" do223 wait = Selenium::WebDriver::Wait.new(timeout: 15)224 driver = Selenium::WebDriver.for driver_name, options: driver_options225 driver.manage.window.size = Selenium::WebDriver::Dimension.new(1920, 1080)226 driver.navigate.to url227 wait.until { driver.find_elements(:xpath, "//div[@class='catogory']") }228 driver229 .find_elements(:xpath, "//a[@class='btn-link collapse-btn']")230 .first231 .click()232 wait.until { driver.find_elements(:xpath, "//span[@class='icon-label hidden-xs']") }233 driver234 .find_element(:css, "ul.sidebar-nav")235 .find_elements(:xpath, "//li[@class='has-sub-menu']")236 .select{ |i| i.attribute("href") == nil }237 .each { |i|238 i.find_element(:tag_name, "a").click()239 if do_screenshots240 driver.save_screenshot("screen_" + c.to_s + ".png")241 c = c + 1242 end243 expect(driver.find_element(:css, "ul.sub-menu").displayed?).to eq(true)244 }245 driver246 .find_element(:css, "ul.sidebar-nav")247 .find_elements(:xpath, "//li[@class='sub-menu-item']")248 .select { |i| i.text.downcase == 'vga configuration' }249 .each { |i|250 i.click()251 if do_screenshots252 driver.save_screenshot("screen_" + c.to_s + ".png")253 c = c + 1254 end255 driver256 .find_elements(:xpath, "//ul[@class='nav nav-tabs']//li")257 .each { |j|258 j.click()259 wait.until { driver.find_elements(:xpath, "//dev[@class='nav nav-tabs']//li[@class='active']") }260 if do_screenshots261 driver.save_screenshot("screen_" + c.to_s + ".png")262 c = c + 1263 end264 expect(driver.find_element(:css, "div.tab-content").displayed?).to eq(true)265 }266 }267 driver.quit268 end269end270RSpec.describe "test editor in extended info" do271 it "- editor should be displayed" do272 wait = Selenium::WebDriver::Wait.new(timeout: 15)273 driver = Selenium::WebDriver.for driver_name, options: driver_options274 driver.manage.window.size = Selenium::WebDriver::Dimension.new(1920, 1080)275 driver.navigate.to url276 wait.until { driver.find_elements(:xpath, "//div[@class='catogory']") }277 driver278 .find_elements(:xpath, "//a[@class='btn-link collapse-btn']")279 .first280 .click()281 wait.until { driver.find_elements(:xpath, "//span[@class='icon-label hidden-xs']") }282 driver283 .find_element(:css, "ul.sidebar-nav")284 .find_elements(:xpath, "//li[@class='has-sub-menu']")285 .select{ |i| i.attribute("href") == nil }286 .each { |i|287 i.find_element(:tag_name, "a").click()288 if do_screenshots289 driver.save_screenshot("screen_" + c.to_s + ".png")290 c = c + 1291 end292 expect(driver.find_element(:css, "ul.sub-menu").displayed?).to eq(true)293 }294 driver295 .find_element(:css, "ul.sidebar-nav")296 .find_elements(:xpath, "//li[@class='sub-menu-item']")297 .select { |i| i.text.downcase == 'extended info' }298 .each { |i|299 i.click()300 sleep 1301 if do_screenshots302 driver.save_screenshot("screen_" + c.to_s + ".png")303 c = c + 1304 end305 expect(driver.find_element(:xpath, "//div[@id='editor']").displayed?).to eq(true)306 }307 driver.quit308 end309end310RSpec.describe "test panels in log" do311 it "- panels should be displayed" do312 wait = Selenium::WebDriver::Wait.new(timeout: 15)313 driver = Selenium::WebDriver.for driver_name, options: driver_options314 driver.manage.window.size = Selenium::WebDriver::Dimension.new(1920, 1080)315 driver.navigate.to url316 wait.until { driver.find_elements(:xpath, "//div[@class='catogory']") }317 driver318 .find_elements(:xpath, "//a[@class='btn-link collapse-btn']")319 .first320 .click()321 wait.until { driver.find_elements(:xpath, "//span[@class='icon-label hidden-xs']") }322 driver323 .find_element(:css, "ul.sidebar-nav")324 .find_elements(:xpath, "//li[@class='has-sub-menu']")325 .select{ |i| i.attribute("href") == nil }326 .each { |i|327 i.find_element(:tag_name, "a").click()328 if do_screenshots329 driver.save_screenshot("screen_" + c.to_s + ".png")330 c = c + 1331 end332 expect(driver.find_element(:css, "ul.sub-menu").displayed?).to eq(true)333 }334 driver335 .find_element(:css, "ul.sidebar-nav")336 .find_elements(:xpath, "//li[@class='sub-menu-item']")337 .select { |i| i.text.downcase == 'log' }338 .each { |i|339 i.click()340 if do_screenshots341 driver.save_screenshot("screen_" + c.to_s + ".png")...

Full Screen

Full Screen

all_steps.rb

Source:all_steps.rb Github

copy

Full Screen

...7end8Then /^I select "([^\"]*)"$/ do |text|9 begin10 a=@driver.find_element(:name,'realmId') #realmId should be the html tag name of select tag11 options=a.find_elements(:tag_name=>"option") # all the options of that select tag will be selected12 options.each do |g|13 if g.attribute('value') == text || g.text == text14 g.click15 break16 end17 end18 ele=@driver.find_element(:id, "go")19 ele.click20 rescue21 if @driver.page_source.match('SLI Exception')22 ele=false23 puts "SLI Exception"24 elsif Timeout::Error25 puts "TimeOut error"26 else27 raise Selenium::WebDriver::Error::NoSuchElementError28 end29 end30 31end32Then /^I follow all the wsrp links$/ do33 begin34 wsrp_elements= []35 # wsrp_elements=@driver.find_elements(:xpath, "//section [@id='portlet_appselectioninterfaceportlet_WAR_AppSelectionInterfaceportlet']/div/div/div/table/tbody/tr/td/a")36 @driver.find_elements(:xpath, "//a[@href='#']").each do |tt|37 if tt.attribute('onclick') != nil && tt.attribute('onclick').match('callWsrp')38 wsrp_elements << tt39 end40 end41 wsrp_elements.compact!42 wsrp_ele=[]43 wsrp_elements.each do |wsrp|44 wsrp_ele << wsrp.attribute('onclick').gsub("callWsrp","").gsub("(","").gsub(")","").gsub("'","")45 end46 47 wsrp_ele.each do |el|48 @driver.navigate.to el49 puts "successfully open all the #{el} WSRP Page"50 end51 52 53 54 rescue55 if @driver.page_source.match('SLI Exception')56 ele=false57 puts "SLI Exception"58 elsif Timeout::Error59 puts "TimeOut error"60 else61 raise Selenium::WebDriver::Error::NoSuchElementError62 end63 end64 65end66Then /^I am on the wsrp page$/ do67 begin68 text=@driver.find_element(:tag_name => "title").text()69 puts text70 rescue71 if @driver.page_source.match('SLI Exception')72 ele=false73 puts "SLI Exception"74 elsif Timeout::Error75 puts "TimeOut error"76 else77 raise Selenium::WebDriver::Error::NoSuchElementError78 end79 end80end81Then /^I select "([^\"]*)" from "([^\"]*)"$/ do |text,field|82 begin83 #wait = Selenium::WebDriver::Wait.new(:timeout => 10)84 # wait.until{85 a=@driver.find_element(:id, field)86 options=a.find_elements(:tag_name=>"option")87 options.each do |g|88 if g.attribute('value') == text || g.text == text89 g.click90 break91 end92 end93 # }94 rescue95 if @driver.page_source.match('SLI Exception')96 ele=false97 puts "SLI Exception"98 elsif Timeout::Error99 puts "TimeOut error"100 else101 raise Selenium::WebDriver::Error::NoSuchElementError102 end103 end104end105Then /^I click "([^\"]*)"$/ do |btn_text|106 begin107 ele=@driver.find_element(:id, "go")108 ele.click109 rescue110 if @driver.page_source.match('SLI Exception')111 ele=false112 puts "SLI Exception"113 elsif Timeout::Error114 puts "TimeOut error"115 else116 raise Selenium::WebDriver::Error::NoSuchElementError117 end118 end119 #@driver.find_element(:xpath, "//form/input[@value=#{btn_text}]").click120end 121Given /^EULA has been accepted$/ do122end123When /^I go to the login page$/ do124 @driver.navigate.to "https://devlycans.slidev.org/portal"125 begin126 a=@driver.find_element(:name,'realmId') #realmId should be the html tag name of select tag127 ele=true128 if ele == true129 options=a.find_elements(:tag_name=>"option") # all the options of that select tag will be selected130 options.each do |g|131 if g.attribute('value') == '5a4bfe96-1724-4565-9db1-35b3796e3ce1'132 g.click133 break134 end135 end136 ele=@driver.find_element(:id, "go")137 ele.click138 end139 rescue140 if @driver.page_source.match('SLI Exception')141 ele=false142 puts "SLI Exception"143 elsif Timeout::Error144 puts "TimeOut error"145 else146 raise Selenium::WebDriver::Error::NoSuchElementError147 end148 end149 150 151end152Then /^I follow the home page Dashboard$/ do 153 begin154 element= @driver.find_element(:xpath, "//td/a/div[text()=' Dashboard (Integration)']")155 element.click156 rescue157 if @driver.page_source.match('SLI Exception')158 ele=false159 puts "SLI Exception"160 elsif Timeout::Error161 puts "TimeOut error"162 else163 raise Selenium::WebDriver::Error::NoSuchElementError164 end165 end166end167Then /^I should logged out$/ do168 #begin169 #@driver.find_element(:link, 'Sign Out').click170 #rescue171 begin172 173 174 #action=Selenium::WebDriver::ActionBuilder.new(:move_to,nil)175 wait = Selenium::WebDriver::Wait.new(:timeout => 10) 176 wait.until{177 menu = @driver.find_elements(:class,"menulink").first.click()178 submenu=@driver.find_element(:link, 'Logout')179 submenu.click }180 #@driver.action.move_to(menu).perform181 rescue182 183 if @driver.page_source.match('SLI Exception')184 ele=false185 puts "SLI Exception"186 elsif Timeout::Error187 puts "TimeOut error"188 else189 raise Selenium::WebDriver::Error::NoSuchElementError190 end191 192 end193 #submenu=@driver.find_element(:link, 'Logout')194 195 #@driver.action.move_to(menu).click(submenu).perform196 197 #click_link('Logout')198end199Then /^I should be on the home page$/ do200 begin201 ele=@driver.find_element(:xpath, "//input[@value='Agree']")202 element=true203 rescue204 element=false205 end206 if element207 ele.click208 else209 puts "EULA has already been accepted"210 end211 begin212 213 #action=Selenium::WebDriver::ActionBuilder.new(:move_to,nil)214 #@driver.action.move_to(menu).perform215 wait = Selenium::WebDriver::Wait.new(:timeout => 10) 216 wait.until{217 menu = @driver.find_elements(:class,"menulink").first.click()218 submenu=@driver.find_element(:link, 'Logout').displayed? }219 rescue Selenium::WebDriver::Error::NoSuchElementError, Timeout::Error, NoMethodError220 if @driver.page_source.match('SLI Exception')221 ele=false222 puts "SLI Exception"223 elsif Timeout::Error224 puts "TimeOut error"225 elsif NoMethodError226 puts ""227 else228 raise Selenium::WebDriver::Error::NoSuchElementError229 end230 end231 #submenu=@driver.find_element(:link, 'Logout').displayed?232 233 234 #@driver.find_element(:link, 'Sign Out').displayed?235end236And /^I see the EULA Page$/ do237 begin238 ele=@driver.find_element(:xpath, "//input[@value='Agree']")239 ele2=@driver.find_element(:xpath, "//input[@value='Logout']")240 element=true241 rescue242 element=false243 end244 if element == true245 true246 else247 puts "SLI Exception"248 end 249end250When /^I mouseover on menu and click submenu "([^\"]*)"$/ do |submenu|251 begin252 253 #action=Selenium::WebDriver::ActionBuilder.new(:move_to,nil)254 #@driver.action.move_to(menu).perform255 wait = Selenium::WebDriver::Wait.new(:timeout => 10)256 wait.until{257 menu = @driver.find_elements(:class,"menulink").first.click()258 @driver.find_element(:link, submenu).click()}259 rescue260 if @driver.page_source.match('SLI Exception')261 ele=false262 puts "SLI Exception"263 elsif Timeout::Error264 puts "TimeOut error"265 else266 raise Selenium::WebDriver::Error::NoSuchElementError267 end268 end269 #submenu=@driver.find_element(:link, 'Logout')270 # submenu.click271 272end273Given /^I should remove all cookies$/ do274 @driver.manage.delete_all_cookies275end276When /^I login with "([^\"]*)" and "([^\"]*)"$/ do |username, password|277 begin278 @driver.manage.delete_all_cookies279 element = @driver.find_element(:id, 'IDToken1') #the username field id is IDToken1280 element.send_keys username281 element = @driver.find_element(:id, 'IDToken2') #the username field id is IDToken2282 element.send_keys password283 element=@driver.find_element(:class, "Btn1Def")284 element.click285 rescue286 if @driver.page_source.match('SLI Exception')287 ele=false288 puts "SLI Exception"289 elsif Timeout::Error290 puts "TimeOut error"291 else292 raise Selenium::WebDriver::Error::NoSuchElementError293 end294 end295 #wait = Selenium::WebDriver::Wait.new(:timeout => 100) # seconds296 # wait.until { driver.find_element(:link => "Logout") }297end298Then /^I should be on the authentication failed page$/ do299 begin300 @driver.navigate.to "https://devopenam1.slidev.org:80/idp2/UI/Login"301 rescue302 303 if @driver.page_source.match('SLI Exception')304 ele=false305 puts "SLI Exception"306 elsif Timeout::Error307 puts "TimeOut error"308 else309 raise Selenium::WebDriver::Error::NoSuchElementError310 end311 end312 313end314Then /^I click button "([^\"]*)"$/ do |text|315 begin316 wait = Selenium::WebDriver::Wait.new(:timeout => 100)317 wait.until { @driver.find_element(:xpath, "//span/input[@value='#{text}']")318 @driver.find_element(:xpath, "//span/input[@value='#{text}']").click319 320 }321 322 rescue323 if @driver.page_source.match('SLI Exception')324 ele=false325 puts "SLI Exception"326 elsif Timeout::Error327 puts "TimeOut error"328 else329 raise Selenium::WebDriver::Error::NoSuchElementError330 end331 end332 333end334Then /^I should be on the admin page$/ do335 #begin336 #wait = Selenium::WebDriver::Wait.new(:timeout => 10)337 #wait.until{338 if @driver.find_element(:link, "Admin").displayed? 339 puts "On the admin Page"340 else341 puts "Not an admin Page"342 end343 # }344 345 #rescue346 #if @driver.page_source.match('SLI Exception')347 # ele=false348 # puts "SLI Exception"349 # elsif Timeout::Error350 # puts "TimeOut error"351 # else352 # raise Selenium::WebDriver::Error::NoSuchElementError353 # end354 #end355end356And /^I select the "([^\"]*)"$/ do |sel|357 #wait = Selenium::WebDriver::Wait.new(:timeout => 10)358 #wait.until{359 select=@driver.find_element(:tag_name, 'select')360 options=select.find_elements(:tag_name, "option")361 options.each do |g|362 if g.attribute('value') == sel363 g.click364 break365 end366 end367end368And /^I click "([^\"]*)"$/ do |btn|369 370 371end372Then /^It open a popup$/ do373 wait = Selenium::WebDriver::Wait.new(:timeout => 10)374 wait.until{375 frame=@driver.find_element(:tag_name, "iframe")376 @driver.switch_to.frame(frame)377 378 }379 380end381Then /^I should see "([^"]*)" as "([^"]*)"$/ do |field,text|382 begin383 if @driver.find_element(:id, field).text == text384 val=true385 else386 val=false387 puts "DEFECT:-The Description text box retains earlier text after reporting a problem"388 end389 ...

Full Screen

Full Screen

web_helper.rb

Source:web_helper.rb Github

copy

Full Screen

...79 expect(properties[property_index].text).to eq("#{expected_property[:label]}:")80 value = if expected_property[:tag].nil?81 values[property_index].text82 elsif expected_property[:tag] == 'img'83 values[property_index].find_element(tag_name: 'div').attribute('innerHTML')84 else85 values[property_index].find_element(tag_name: expected_property[:tag]).text86 end87 expect(value).to eq(expected_property[:value])88 property_index += 189 end90 end91 def check_filter_link(tab_id, link_index, target_tab_id, expected_filter)92 # TODO: Behavior of selenium-webdriver. Entire item must be displayed for it to click. Workaround following two lines after commented out code93 # Selenium::WebDriver::Wait.new(timeout: 5).until { @driver.find_elements(xpath: "//div[@id='#{tab_id}PropertiesContainer']/table/tr[*]/td[2]")[link_index].find_element(tag_name: 'a').click }94 element = @driver.find_elements(xpath: "//div[@id='#{tab_id}PropertiesContainer']/table/tr[*]/td[2]")[link_index].find_element(tag_name: 'a')95 @driver.execute_script('arguments[0].click();', element)96 expect(Selenium::WebDriver::Wait.new(timeout: 5).until { @driver.find_element(class_name: 'menuItemSelected').attribute('id') }).to eq(target_tab_id)97 expect(Selenium::WebDriver::Wait.new(timeout: 5).until { @driver.find_element(id: target_tab_id).displayed? }).to eq(true)98 expect(Selenium::WebDriver::Wait.new(timeout: 5).until { @driver.find_element(id: "#{target_tab_id}Table_filter").find_element(tag_name: 'input').attribute('value') }).to eq(expected_filter)99 end100 def check_stats_chart(id)101 begin102 Selenium::WebDriver::Wait.new(timeout: 5).until { @driver.find_element(id: "#{id}Chart").displayed? }103 rescue Selenium::WebDriver::Error::TimeoutError, Selenium::WebDriver::Error::StaleElementReferenceError104 end105 chart = @driver.find_element(id: "#{id}Chart")106 expect(chart.displayed?).to be(true)107 rows = chart.find_elements(xpath: "//table[@class='jqplot-table-legend']/tr")108 expect(rows[0].text).to eq('Organizations')109 expect(rows[1].text).to eq('Spaces')110 expect(rows[2].text).to eq('Users')111 expect(rows[3].text).to eq('Apps')112 expect(rows[4].text).to eq('Total Instances')...

Full Screen

Full Screen

sel.rb

Source:sel.rb Github

copy

Full Screen

...7driver.navigate.to "http://www.3plea.com/memberLogin.asp"8#element = driver.find_element(:name, 'q')9#element.send_keys "Hello WebDriver!"10#element = driver.find_element(:name,'Login ID')11element = driver.find_elements(:tag_name, "input")[0]12element.send_keys "adnan9"13#element = driver.find_element(:name,'Password')14element = driver.find_elements(:tag_name, "input")[1]15element.send_keys "660066"16key = driver.find_elements(:tag_name, "font")[6].text17element = driver.find_elements(:tag_name, "input")[2]18element.send_keys "#{key.split(".").join("")}"19driver.find_elements(:tag_name, "input")[3].click20def current_date21 time = Time.now22 time.strftime("%Y%m%d")23end24def today_bonus(driver)25 driver.navigate.to("http://www.3plea.com/member/mCABReportD.asp?DX=#{current_date}")26 counts = driver.find_elements(:tag_name, "a")27 wa = 028 adv_ids = []29 counts.each do |count|30 if count.attribute("href") =~ /adv.asp/31 wa = wa+132 puts count.attribute("href")33 adv_ids << count.attribute("href").split("?")[1].split("=")[1]34 end35 end36 return wa, adv_ids37end 38def find_links(driver, x=1, *adv_ids)39 if x == 140 driver.navigate.to "http://www.3plea.com/member/cads.asp"41 else42 driver.navigate.to "http://www.3plea.com/member/cads.asp?page=#{x}&cx=0"43 end44 links = driver.find_elements(:tag_name, "a")45 adv_links = []46 links.each do |link| 47 #puts link.attribute("href") 48 if link.attribute("href") =~ /adv.asp/49 unless adv_ids.include?link.attribute("href").split("?")[1].split("=")[1]50 adv_links << link.attribute("href")51 puts link.attribute("href")52 else53 puts "Already exist: #{link.attribute('href')} "54 end55 end56 end57 return *adv_links58end59wa, adv_ids = today_bonus(driver)60puts "Total clicks: #{wa}"61x = 162wb = wa63page = 164while wb < 565 adv_links = find_links(driver, page, *adv_ids)66 adv_links.each do |adv_link|67 driver.navigate.to("#{adv_link}")68 #element = driver.find_elements(:tag_name, "a")[20].click if driver.find_elements(:tag_name, "a")[20]69 begin 70 e = driver.find_elements(:tag_name, "a")[19].attribute("href") if driver.find_elements(:tag_name, "a")[19].attribute("href")71 if e =~ /clickadv.asp/72 if wa < 573 puts "#{x} #{e}"74 driver.find_elements(:tag_name, "a")[19].click75 sleep 576 x=x+177 sleep 5+Random.rand(1)78 wa = wa + 179 else80 puts "skipping"81 end82 end83 rescue84 next85 end86 end87 puts "Robot.click: #{wa}"88 sleep 1089 next_page = driver.find_elements(:tag_name, "a")90 next_page.each do |link| 91 #puts link.attribute("href") 92 if link.attribute("href") =~ /cads.asp\?page=2/93 page = 294 else95 page = 196 end97 end98 wb, adv_ids = today_bonus(driver)99 wa = wb100end101puts "Total clicks: #{wb}"102#driver.navigate.to("http://www.3plea.com/member/logout.asp")103#element.submit...

Full Screen

Full Screen

selenium_page_object_spec.rb

Source:selenium_page_object_spec.rb Github

copy

Full Screen

...12 selenium_browser.stub(:switch_to).and_return(selenium_browser)13 selenium_browser.stub(:default_content)14 end15 context "when building identifiers hash" do16 it "should add tag_name when identifying by text for hidden_field" do17 expected_identifier = {:text => 'foo', :tag_name => 'input', :type => 'hidden'}18 PageObject::Elements::HiddenField.should_receive(:selenium_identifier_for).with(expected_identifier)19 selenium_browser.should_receive(:find_element)20 selenium_page_object.platform.hidden_field_for(:text => 'foo')21 end22 it "should add tag_name when identifying by href for anchor" do23 expected_identifier = {:href => 'foo', :tag_name => 'a'}24 PageObject::Elements::Link.should_receive(:selenium_identifier_for).with(expected_identifier)25 selenium_browser.should_receive(:find_element)26 selenium_page_object.platform.link_for(:href => 'foo')27 end28 29 it "should add tag_name when identifying by text for div" do30 expected_identifier = {:text => 'foo', :tag_name => 'div'}31 PageObject::Elements::Div.should_receive(:selenium_identifier_for).with(expected_identifier)32 selenium_browser.should_receive(:find_element)33 selenium_page_object.platform.div_for(:text => 'foo')34 end35 end36 context "when trying to find an element that does not exist" do37 it "should return a surogate selenium object" do38 selenium_browser.should_receive(:find_element).and_raise(Selenium::WebDriver::Error::NoSuchElementError)39 page = SeleniumTestPageObject.new(selenium_browser)40 element = page.link_element(:text => 'blah')41 element.element.should be_instance_of PageObject::Platforms::SeleniumWebDriver::SurrogateSeleniumElement42 end43 it "should know it is not exist" do44 selenium_browser.should_receive(:find_element).twice.and_raise(Selenium::WebDriver::Error::NoSuchElementError)...

Full Screen

Full Screen

tag_name

Using AI Code Generation

copy

Full Screen

1element = driver.find_element(:name, 'q')2element = driver.find_element(:name, 'q')3element = driver.find_element(:name, 'q')4element = driver.find_element(:name, 'q')5element = driver.find_element(:name, 'q')6element = driver.find_element(:name, 'q')

Full Screen

Full Screen

tag_name

Using AI Code Generation

copy

Full Screen

1driver.find_element(:name, 'q').send_keys "Selenium WebDriver"2driver.find_element(:name, 'btnG').click3wait.until { driver.title.downcase.start_with? "selenium webdriver" }4puts "Page contains 'Selenium WebDriver' text" if driver.find_element(:tag_name, 'body').text.include? "Selenium WebDriver"

Full Screen

Full Screen

tag_name

Using AI Code Generation

copy

Full Screen

1driver.find_element(:name, "q").send_keys "Hello World"2driver.find_element(:name, "btnG").click3driver.find_element(:name, "q").send_keys "Hello World"4driver.find_element(:name, "btnG").click5driver.find_element(:name, "q").send_keys "Hello World"6driver.find_element(:name, "btnG").click7driver.find_element(:name, "q").send_keys "Hello World"8driver.find_element(:name, "btnG").click9driver.find_element(:name, "q").send_keys "Hello World"10driver.find_element(:name, "btnG").click11driver.find_element(:name, "q").send_keys "Hello World"12driver.find_element(:name, "btnG").click13driver.find_element(:name

Full Screen

Full Screen

tag_name

Using AI Code Generation

copy

Full Screen

1driver.find_element(:id, "lst-ib").send_keys "Hello World"2driver.find_element(:name, "btnK").click3element = driver.find_element(:id, "lst-ib")4element = driver.find_element(:id, "lst-ib")5element = driver.find_element(:id, "lst-ib")6element = driver.find_element(:id, "lst-ib")7element = driver.find_element(:id, "lst-ib")8element = driver.find_element(:id, "lst-ib")9element = driver.find_element(:id, "lst-ib")

Full Screen

Full Screen

tag_name

Using AI Code Generation

copy

Full Screen

1element = driver.find_element(:name, 'q')2element = driver.find_element(:name, 'q')3element = driver.find_element(:name, 'q')4element = driver.find_element(:name, 'q')5element = driver.find_element(:name, 'q')

Full Screen

Full Screen

tag_name

Using AI Code Generation

copy

Full Screen

1element = driver.find_element(:name, 'q')2Related Posts: Python Selenium WebDriver get_attribute() method3Python Selenium WebDriver get_property() method4Python Selenium WebDriver get_text() method5Python Selenium WebDriver is_displayed() method6Python Selenium WebDriver is_enabled() method7Python Selenium WebDriver is_selected() method8Python Selenium WebDriver submit() method9Python Selenium WebDriver clear() method10Python Selenium WebDriver send_keys() method11Python Selenium WebDriver get_attribute() method12Python Selenium WebDriver get_property() method13Python Selenium WebDriver get_text() method14Python Selenium WebDriver is_displayed() method15Python Selenium WebDriver is_enabled() method16Python Selenium WebDriver is_selected() method17Python Selenium WebDriver submit() method18Python Selenium WebDriver clear() method19Python Selenium WebDriver send_keys() method20Python Selenium WebDriver get_attribute() method21Python Selenium WebDriver get_property() method

Full Screen

Full Screen

tag_name

Using AI Code Generation

copy

Full Screen

1driver.find_element(:name, 'q').send_keys "selenium"2driver.find_element(:name, 'btnG').click3puts driver.find_element(:id, 'resultStats').tag_name4driver.find_element(:name, 'q').send_keys "selenium"5driver.find_element(:name, 'btnG').click6puts driver.find_element(:id, 'resultStats').text7driver.find_element(:name, 'q').send_keys "selenium"8driver.find_element(:name, 'btnG').click9driver.find_element(:name, 'q').send_keys "selenium"10driver.find_element(:name, 'btnG').click

Full Screen

Full Screen

tag_name

Using AI Code Generation

copy

Full Screen

1driver.find_element(:name, "q").send_keys "Hello World"2driver.find_element(:name, "btnG").click3driver.find_element(:name, "q").send_keys "Hello World"4driver.find_element(:name, "btnG").click5driver.find_element(:name, "q").send_keys "Hello World"6driver.find_element(:name, "btnG").click7driver.find_element(:name

Full Screen

Full Screen

tag_name

Using AI Code Generation

copy

Full Screen

1driver.find_element(:id, "lst-ib").send_keys "Hello World"2driver.find_element(:name, "btnK").click3element = driver.find_element(:id, "lst-ib")4element = driver.find_element(:id, "lst-ib")5element = driver.find_element(:id, "lst-ib")6element = driver.find_element(:id, "lst-ib")7element = driver.find_element(:id, "lst-ib")8element = driver.find_element(:id, "lst-ib")9element = driver.find_element(:id, "lst-ib")

Full Screen

Full Screen

tag_name

Using AI Code Generation

copy

Full Screen

1element = driver.find_element(:name, 'q')2element = driver.find_element(:name, 'q')3element = driver.find_element(:name, 'q')4element = driver.find_element(:name, 'q')5element = driver.find_element(:name, 'q')

Full Screen

Full Screen

tag_name

Using AI Code Generation

copy

Full Screen

1driver.find_element(:name, 'q').send_keys "selenium"2driver.find_element(:name, 'btnG').click3puts driver.find_element(:id, 'resultStats').tag_name4driver.find_element(:name, 'q').send_keys "selenium"5driver.find_element(:name, 'btnG').click6puts driver.find_element(:id, 'resultStats').text7driver.find_element(:name, 'q').send_keys "selenium"8driver.find_element(:name, 'btnG').click9driver.find_element(:name, 'q').send_keys "selenium"10driver.find_element(:name, 'btnG').click

Full Screen

Full Screen

tag_name

Using AI Code Generation

copy

Full Screen

1driver.find_element(:id, "lst-ib").send_keys "Hello World"2driver.find_element(:name, "btnK").click3element = driver.find_element(:id, "lst-ib")4element = driver.find_element(:id, "lst-ib")5element = driver.find_element(:id, "lst-ib")6element = driver.find_element(:id, "lst-ib")7element = driver.find_element(:id, "lst-ib")8element = driver.find_element(:id, "lst-ib")9element = driver.find_element(:id, "lst-ib")

Full Screen

Full Screen

tag_name

Using AI Code Generation

copy

Full Screen

1element = driver.find_element(:name, 'q')2element = driver.find_element(:name, 'q')3element = driver.find_element(:name, 'q')4element = driver.find_element(:name, 'q')5element = driver.find_element(:name, 'q')

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Selenium automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful