Selenium: How to locate all the images on a webpage without knowing their id or name attribute? - selenium

Let us say, I loaded a URI with selenium. I have no idea how the elements are named in that page (I do not know the id, name ... of elements). I want to download all the possible pictures that may exist on that webpage. This problem is solved through the first answer of this question. But how can I located with selenium all the pictures that exist on that webpage ?
I checked answers for similar questions like this one but the answers are not useful.

The easiest way is to find by tag name as all images will have an image tag you can just get every element on that page with that tag. In python i believe it will be using (note note find_element_by_tag_name as that would return just one of the elements)
find_elements_by_tag_name
and you will want to find elements with the img tag http://www.w3schools.com/tags/tag_img.asp

If I'm not mistaken, you can do something like this
driver.find_element_by_tag_name('img')
Hope that's help.

Related

How to find out broken links/ images throughout all the pages of a website using selenium WebDriver?

I can find broken inks/ images in any particular webpage. But I am not able to find it throughout all the pages using Selenium. I have gone through many blogs but didn't find any code working. It would be great help if anyone one of you could help me to fix this problem
Collect all the href attribute in your page using the 'a' and 'img' tagname in a list.
In java, iterate the loop,setup a HttpURLCOnnection for each url from the href list. Connect to it and check the response code. Google for logic and error codes responses.
If you want to check broken images for all the pages, you can use HTTPClient library to check status codes of the images on a page.
First try to find all images on each page by using Webdriver.
Below is the syntax:
List<WebElement> imagesList = driver.findElements(By.tagName("img"));
Below is the syntax to get links
List<WebElement> anchorTagsList = driver.findElements(By.tagName("a"));
Now you need to iterate through each image and verify response code with HttpStatus.
You can find example from here Find Broken / Invalid Images on a Page
You can find example from here Find Broken Links on a Page

How do I include a picture in a page element in Inquisit?

I'd like to include a picture in a page element in an Inquest script: is this possible?
If so, how would you do it?
I know this question was asked 8 years ago...but I recently had the same question. So I thought maybe I could put something here in case someone in the future would have a similar question.
You cannot add a picture to the page element in Inquisit 5, but it would be possible in Inquisit 6. For Inquisit 5, you'll have to use or .
Here's some discussion on this: https://forums.millisecond.com/Topic34836.aspx
There is some discussion here.
In general, it seems that the page element only allows for simple text based instructions.
If you want to present images in instructions, there are a few options.
htmlpage element
You can use the htmlpage element, which allows for instructions to be a complete formatted HTML file that can include images.
The htmlpage element is used to define pages of text to be displayed
as instructions using the preinstructions or postinstructions
attribute. The htmlpage element is useful when complete control over
formatting and content of instruction pages is required, otherwise the
page element provides an easier way to display text with basic
formatting. The actual content of the page is contained in a separate
HTML file located on the local machine or the web. source
Picture or picture and text in a normal trial
The other option is to present instructions as normal stimuli in the main trials of a block.
See for example, the instructions in the sample script for the Iowa Gambling Task.
This can be either done as one integrated picture that includes text, or each image can be positioned as it's own stimuli.

Gallery with mixed content types

Gallery with mixed content types, it always opens the first element, should open the clicked element
http://codepen.io/anon/pen/KvcCJ
Simple example with just images, works fine.
http://codepen.io/dimsemenov/pen/qruJz
Thank you
Question was resolved on GitHub https://github.com/dimsemenov/Magnific-Popup/issues/146

parsing html data iphone xpath

have this webpage http://www.westminster.ac.uk/schools/computing/undergraduate . I'm using hpple to retrieve data (just started learning about it). I want to specifically retrieve the href from he main page, how can i do this?
I have this line - "NSArray *elements = [xpathParser search:#"//a"];" is able to retrieve all of the href links within the page however how can i retrieve just the ones in the main content? e.g. "BSc Honors Busniess Information Systems"? whats the syntax for it?
It looks like all of the "main content" stuff is found underneath elements with id attributes like "content_div_XXXX" where XXXX is some randomly generated sequence. You might be able to get at what you want using an XPath that looks something like:
//div[starts-with(#id,'content_div')]//a
You should be able to get something like this working, although you'd have to try it out and perhaps tweak it a bit to make it work precisely as you want. Refer to W3Schools XPath page for a good set of XPath tutorials

Dynamic Div placement based on number of values in a list

I want to be able to change the design of the website based on the content in my database. For example: I have a list of instances of objects that is being pulled from a database, and will be used to populate my website. I want the website to look similar to www.reddit.com, where there is a <div> for each post. However, I can't figure out how to variably change the location of that <div>. So for the first instance of that object it will be located at top:60px; the second top:200px; etc... (not those exact numbers). If you need any clari
Was looking for some help! Thanks,
Figured it out! I added a variable that I then used to define the "top:" in the html of the template. If anyone wants me to explain further please let me know.