I have the following screen
And this is my ruby steps for clicking the "STATUS" tab.
And(/^Click The Status Tab$/) do
# statusTab = driver.link(id: "tab3")
statusTab = driver.link visible_text: "STATUS"
statusTab.wait_until_present
if statusTab.exists?
statusTab.click
puts "Status Tab Clicked"
else
fail "Could NOT locate Status Tab"
end
end
As you can see in my code above, I have tried using the locator "link" by 'id' and 'visible_text'.
The code above works fine in my local computer. I have tried running it using chromedriver and chromedriver in headless mode. I have tried using Jenkins in my local computer, too.
But, it failed when running it in Jenkins server in the AWS.
I got the following error in my cucumber report:
unknown error: Element <em>...</em> is not clickable at point (146, 16). Other element would receive the click: <li>...</li>
(Session info: headless chrome=62.0.3202.62)
(Driver info: chromedriver=2.33.506092 (733a02544d189eeb751fe0d7ddca79a0ee28cce4),platform=Linux 4.4.0-1039-aws x86_64) (Selenium::WebDriver::Error::UnknownError)
Is there a way to tackle this issue?
Most of the time that something works in a real browser, but not headless is due to a difference in the size of the actual browser window. Headless seems to open in a smaller window, which can cause two things to happen
1) element may be off-screen and can't be scrolled to for some reason
2) (especially typical of reactive sites that arrange to fit space allowed) the site ends up arranged such that another element is covering the one you are trying to click.
The clue to which is the case is usually in the error message. In your case the text Other element would receive the click is telling you that something else has covered up the thing you are trying to click on.
Try setting the browser window size right after you create your browser/driver object. If you are using Watir the command usually looks something like this
browser.window.resize_to(1024, 768)
Generally I talk to the PO and ask what the minimum supported screen size (assuming a maximized browser window) is, and set the browser to that size. Often if tablet browsing is to be supported without a special mobile site, the smallest supported screen size will beo 1024x786 or 768x1024 (depending if portrait or landscape orientation is assumed)
Related
I have one page that launches another page, and the launched page does a series of scrapes and then plays an audio based on the results.
This stopped working today, maybe because of a Firefox update, but I need to be able to enable auto play as it is critical that the audio plays when the launched page loads.
Here is what my current JavaScript code looks like:
function playHighRiskStock(){
var highRiskStock = new Audio('./wav/high-risk.wav');
highRiskStock.play();
}
It is now giving me the error: NotAllowedError: The play method is not allowed by the user agent or the platform in the current context, possibly because the user denied permission.
It did this all-of-a-sudden (i.e. it was working perfectly yesterday autoplaying with no problems).
How do I configure my browser to allow autoplay, even if not initiated by the user?
I have looked at this page: https://developer.mozilla.org/en-US/docs/Web/Media/Autoplay_guide but it doesn't give any actual JavaScript code examples on setting auto play.
I got the same error in Firefox. The following fixed it for me. Didn't need a reboot or to reload the browser.
Click the Hamburger (Options Menu).
Pick the Options menu.
In the search textbox, enter "Sound".
A "Block websites from automatically playing sound" option will appear.
Either uncheck that option or click the "Exceptions" button beside it. In my case, I added an exception for https://app.pluralsight.com. It works fine now.
Another option is to use Chrome.
Good luck.
I have a simple set of HTML and JS which when I test it directly as a web page, loaded locally from the file system in Chrome, works fine. I can click a button causing a call to navigator.bluetooth.requestDevice. This correctly causes the usual window to appear and it lists the expected Bluetooth peripheral. I can then select it and successfully pair, with my code receiving the expected callback.
If I try to execute the same html/js as a Chrome app, with a manifest and invoked from chrome://extensions the requestDevice window appears and lists the expected peripheral with the Pair button disabled. If I select the peripheral, the Pair button becomes enabled but if I click it, the window disappears into the background, behind Chrome and nothing else happens that I can see. My code receives no callback. It looks like the call was competely ignored.
What do I need to do to make this work within a Chrome app?
Thanks
Chrome Apps and Extensions should be able to use Web Bluetooth. This is a bug. I've filed chromium issue 751819.
As a work around, create the Chrome App window larger than the device chooser dialog that pops up.
I know there is a function called browser.window.move_to(0, 0) to move the browser into different position, but the OSX 10.9 is completely new for it.
Are there any methods can be used to move the browser to another desktop? E.g. Console to trigger command in "Desktop 2", but I want the browser appear in "Desktop 1".
Many thanks!
Ha, I was about to say this probably isn't possible before I tried this:
browser.window.move_to(-1200,0)
My second monitor is oriented to the left of my main screen. It worked. Nice question.
You'll need to fool around with it to get it right but watir appears to be able to use the entire canvas of monitors. If your monitor was above your main screen for example you'd move it there using something like
browser.window.move_to(0,-1000)
Does any one know of a way for selenium to capture the "Waiting for www.google.com" type of info that is displayed on the bottom left/right of a browser?
The purpose of obtaining this message is, so that I can avoid taking a full-screen(as compared to browser screen capture) shot to capture if a page does not load.
I dont want to only know if a page does not load, I also want to know what went wrong. As all these scripts are running off jenkins, on a remote server and there is no physical eye monitoring how the scripts run.
Any help will be much appreciated,
I need to run several instances of a Ruby script that's using the Watir gem, and they all need to be able to run in IE fullscreen mode.
CLARIFICATION: They need to be able to open IE in a mode that allows multiple instances of IE to operate in full screen mode, not necessarily trigger the fullscreen. Opening up IE normally allows only a single instance to open fullscreen (not maximized).
I can make this happen manually, by specifying the '-f' parameter on iexplore.exe. Is there a way to make this happen when creating the browser object from Watir?
If I can't make it happen when this as some sort of runtime parameter, I'd be ok with changing the base Watir call that opens IE - if I could and could find it.
require 'watir'
browser = Watir::Browser.new <--- adding '-f' somehow here?
Try this, it worked for me on IE 9.
browser = Watir::Browser.new
browser.goto 'http://www.google.com'
browser.getIE.parent.FullScreen = true
Edit: I found a registry setting that may do what you are trying.
[HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main]
Fullscreen = "yes" (Default = "no")
Did you try
browser.maximize
It only works on IE, but it is an option that's been documented for a while (see the watir cheat-sheet)
Of course you need perhaps to consider WHY the browser needs to run full screen, or what happens if you move the scripts to a system where the default screen size is different. You might be better off to set the browser to a specific size, which can be done with a simple javascript resizeTo function, you can even 'goto' it as a URL
browser.goto('javascript:resizeTo(800,600)')
There is also a 'moveTo' that can be used the same way. so you can position the window at a known point.
If you need the browser in a particular place and size, something else to consider would be creating a page with the proper javascript to set things they way you want and then make that your default homepage so it runs as soon as the browser opens. If your google for 'javascript maximize browser' or 'javascript resize browser' you will likely find example code for such a page.
=-=-=-= Edit (based on clarification that 'fullscreen' is what is wanted, not merely maximized)
Lastly you could look at simply simulating a 'F11' keypress as that is the fullscreen toggle for most browsers. If you are using watir-webdriver this can be done via the sendkeys method
browser.send_keys :f11
However that is a toggle, and in a script would depend on things being in the right state to start with. Something that got out of sync might end up turning 'off' the fullscreen.
So you might investigate also the idea of a specific page on the local system that would spawn a new fullscreen window, and having the code attach to the new window. (or using the switching window code in watir-webdriver) although this sort of 'popup a new window in fullscreen mode' is something you might expect to be blocked or deprecated (see below) in the future if not already on some browsers.
Warning: being able to throw the browser into fullscreen mode from the HTML is something that is somewhat frowned upon because it is considered a security vulnerability. This is because someone could craft a specific image to make it LOOK like a url bar and other controls were present, and the user at a legitimate site, when creating a phishing site. Such sites are currently one of the larger issues the web community faces right now (contents of my spamfilter are about 20% phishing and rising rapidly) So while there may have been methods in the past to do that, increasingly they get 'shut down' by newer more secure versions of browsers. This might tend to make the sendkeys option your best bet going forward in terms of something that should work cross browser. (nearly all that I know of use F11 for the fullscreen toggle)
-k puts IE into a full screen kiosk mode that is more than F11. There are no toolbars, menus, icons, etc. You have to hit Alt+F4 to close it and you can Alt+Tab to other open tasks.
Feels hackish, but I figured out I can do something like (but I'd love a better way):
require 'watir'
IO.popen('C:\\Program Files\\Internet Explorer\\iexplore.exe -f "newwindow"')
browser = Watir::IE.attach(:title,/newwindow/)