browser-automation

Browser detection using user agent in fixture hooks

旧时模样 提交于 2020-01-15 03:54:07
问题 I have a few tests that only need to be run when in a mobile browser. Currently I have a client function to check the user agent. const checkMobile = ClientFunction(() => /iPhone|Android/i.test(navigator.userAgent)) Which I then access inside my tests: test("Check if mobile", async t => { const isMobile = await checkMobile(); if (isMobile) { await t // do the tests } } Is there a way for me to use this in a fixture? Like a fixture which will only run if checkMobile is true ? So I don't need

Nightmare JS not working

时间秒杀一切 提交于 2020-01-11 09:03:52
问题 I know the title of the question looks very vague! But that's there's to it. I installed nodejs on my production server, which had phantomjs working properly, then I installed nightmare via npm install nightmare , I can see it in node_modules, I tried the example listed by the developers on github: var Nightmare = require('nightmare'); var nightmare = Nightmare({ show: true }) nightmare .goto('http://yahoo.com') .type('input[title="Search"]', 'github nightmare') .click('#uh-search-button')

iMacros: click button or do not click (random choice)

浪尽此生 提交于 2020-01-05 09:23:57
问题 How can I set random choice for button 'click' or 'don't click'? In this example I need let iMacros make random action between like action and do nothing. TAG POS=1 TYPE=BUTTON ATTR=TXT:Like 回答1: As one of the ways to do what you need: SET butTxt "Like" SET butTxt EVAL("(Math.floor(2*Math.random()) == 0) ? 'No such button!' : '{{butTxt}}';") SET !ERRORIGNORE YES SET !TIMEOUT_STEP 0 TAG POS=1 TYPE=BUTTON ATTR=TXT:{{butTxt}} SET !ERRORIGNORE NO SET !TIMEOUT_STEP 6 回答2: var macro; macro = "CODE:

iMacros: click button or do not click (random choice)

这一生的挚爱 提交于 2020-01-05 09:22:46
问题 How can I set random choice for button 'click' or 'don't click'? In this example I need let iMacros make random action between like action and do nothing. TAG POS=1 TYPE=BUTTON ATTR=TXT:Like 回答1: As one of the ways to do what you need: SET butTxt "Like" SET butTxt EVAL("(Math.floor(2*Math.random()) == 0) ? 'No such button!' : '{{butTxt}}';") SET !ERRORIGNORE YES SET !TIMEOUT_STEP 0 TAG POS=1 TYPE=BUTTON ATTR=TXT:{{butTxt}} SET !ERRORIGNORE NO SET !TIMEOUT_STEP 6 回答2: var macro; macro = "CODE:

Use PowerShell to automate website login and file download

瘦欲@ 提交于 2020-01-05 05:39:11
问题 I want to use PowerShell to automate logging in to a website and downloading a PDF file. There are loads of examples on the internet that show how to do this (using Invoke-WebRequest , WebClient , HttpWebRequest , or InternetExplorer.Application ), but most don't require a login first. Some show it with login, but I can't get them to work. I'm close with using InternetExplorer.Application : $username = "xxxxx" $password = "yyyyy" $url = "https://example.com/login.aspx" $usernameElementId =

How to use multiple locators to find an element in selenium webdriver

折月煮酒 提交于 2020-01-02 07:17:29
问题 How can I locate an element in a page with selenium webdriver by using multiple locators at the same time . I am having 2 elements with same id but different values. So in order to access them I need to use a combination of both id and value. What is the syntax. I'm using java. Also I'm automating an application that works only in IE. Since I'm unable to access xpath, I'm not using it. element=driver.findElement(By.id("id").cssSelector("input[@value='value1']")); 回答1: Xpath allows you to use

WatiN and .net winforms WebBrowser control - is DialogWatcher possible?

老子叫甜甜 提交于 2019-12-29 05:35:10
问题 Our target is: Watin-enabled browser testing embedded in a .net winform. Currently, we are using a .net WebBrowser control to embed browser behavior in a winform. We are attaching WatiN to the WebBroswer control on the form with code like this ( thanks prostynick ): var thread = new Thread(() => { Settings.AutoStartDialogWatcher = false; var ie = new IE(webBrowser1.ActiveXInstance); ie.GoTo("http://www.google.com"); }); thread.SetApartmentState(ApartmentState.STA); thread.Start(); The problem

Internet explorer automation busy v/s readystate property

落花浮王杯 提交于 2019-12-28 18:43:55
问题 I am new to vbscript and while reading i found some code as Do While ie.busy stateString = stateString & " " & cstr(ie.readystate) loop do while ie.readystate <> 4 stateString = stateString & " " & ie.readystate loop so could anyone please let me know what is difference between the busy property and readystate property. 回答1: From here: Michael Harris (MVP) wrote: [...] do until ie.readyState = 4 : wscript.sleep 10 : loop [...] Is there a reason to use do until ie.readyState = 4 : wscript

Webpage automation

浪尽此生 提交于 2019-12-24 15:57:38
问题 I am trying to auto-fetch a screenshot on webpage using VBScript. I am stuck at a point where the VBScript is not able to identify an element which I need to click. Is there any way to identify the element other elementId like xpath/title/value/name which are much more easily identified in Selenium webpage automation. Here is my script: Dim IE Dim Helem Set IE = CreateObject("InternetExplorer.Application") IE.Visible = 1 IE.navigate "https://mylink/logon.jsp" Do While (IE.Busy) WScript.Sleep

WATIR Safari automation Issue

依然范特西╮ 提交于 2019-12-24 10:48:01
问题 I am new to WATIR and I want to automate Safari browser. I am using require 'safariwatir' statement in my ruby file. I am able to open a safari browser window but when I call goto method on my browser object then the result is NIL. It shows FAILED TO OPEN PAGE. Please help me with this. Thanks in advance. 回答1: safariwatir gem is no longer in active development. The last release was three years ago. You should use watir-webdriver gem to drive Safari. 来源: https://stackoverflow.com/questions