Scroll down Google Maps to show all items - c#

how to Scroll down Google Maps to show all items and return to the first item??
I tried more than one using Selenium and Google Drive 109.0.5414.74/ .
All attempts were unsuccessful.
The scroll down only one centimeter and not to the last element. I don't know what the problem is.
my try
` foreach (var item in driver.FindElements(By.XPath("//*[#id='QA0Szd']/div/div/div[1]/div[2]/div/div[1]/div/div/div[2]/div[1]")))
{
driver.FindElement(By.XPath("//*[#id='QA0Szd']/div/div/div[1]/div[2]/div/div[1]")).Click();
Actions actions = new Actions(driver);
actions.SendKeys(OpenQA.Selenium.Keys.PageDown).Build().Perform();
}
`

Related

c# selenium element found but not clicking

im building roulette bot, im finding element by xpath i can get its class attiributes etc. but i cant click on it. its always clickable (bot finds ifrime and then finds element and clicks its working but this website gamescreen in iframe>iframe bot can find button but not clicking)
firefox.SwitchTo().Window(firefox.WindowHandles.Last());
var DBViFrame = firefox.FindElement(By.TagName("iframe"));
firefox.SwitchTo().Frame(DBViFrame);
DBViFrame = firefox.FindElement(By.TagName("iframe"));
firefox.SwitchTo().Frame(DBViFrame);
var dataEntryButton = firefox.FindElement(By.XPath("//*[name()=\"svg\"]//*[name()=\"g\"]//*[name()=\"rect\"][" + num + "]"));
dataEntryButton.Click();
Is firefox your WebDriver? If so, maybe try execute_script and see if that works?
firefox.execute_script("arguments[0].click();", dataEntryButton)

How to scroll with in the chrome browser window

How to scroll to the bottom of the license agreement, which will enable the Accept button? The browser itself does not have a scroll bar; only the agreement has it.
I have googled and tried many different solutions and still can not move the scroll bar., at all.
C# code I've tried. I also tried many other and none is working. Anyone has any idea how to make it work?
IWebElement ScrollBar => DriverContext.Driver.FindElement(By.XPath("//div[#class='frm-scrollbar height-with-eula']"));
Actions act = new Actions(DriverContext.Driver);
act.MoveToElement(ScrollBar).ClickAndHold(ScrollBar).MoveByOffset(0, 1000).Release().Perform();
What Im trying to scroll:
Html for the scroll bar section:
Used this to scroll to the bottom of the page. This works for areas where the scroll bar is inside the webpage itself. Used this in multiple pages for scrolling.
EventFiringWebDriver ef = new(Driver);
// cssStr is the css for the area that includes the scroll bar
cssStr = "div[class=\\\"max-h-370 overflow-y-auto pl-24 pr-24\\\"]";
// 10000 or any number depending on scroll distance in pixels
ef.ExecuteScript("document.querySelector('" + cssStr + "').scrollTop = 10000");
IJavaScriptExecutor js = (IJavaScriptExecutor)DriverContext.Driver;
// by is to be constructed and passed
IWebElement ele = Driver.FindElement(by);
js.ExecuteScript("arguments[0].scrollIntoView(true);", ele);

Xamarin ios Implement Facebook like scrollview

I have a simple table view with dynamic content (images). I would like to implement something similar to a Facebook newsfeed and the ability to select an image from the newsfeed/tableview and get a full sized image with the ability to swipe left and right and a close button to exit the view.
So far I have tried to enable dynamic row heights for my images but they still look squashed and aren't scaled properly.
Unfortunately I have searched in vain for this Facebook like implementation for Xamarin.iOS, which is in c#.
Does anyone know how I can get a similar implementation?
Here's my code for dynamic row heights
if (TableView != null) {
TableView.RowHeight = UITableView.AutomaticDimension;
TableView.EstimatedRowHeight = 44;
TableView.SeparatorStyle = UITableViewCellSeparatorStyle.None;
// Register the TableView's data source
TableView.Source = new HomeControllerSource (dataManager.LoadImages(),this);
}
After a row click,I open up the image in another view controller which has a scrollview but it doesn't fill up the whole screen. I would like to implement this part as Facebook does it.
Thanks.

Selenium-How to iterate through webPage to Find all Necessary elements and perform Click Action

I have a Method for finding the element via Xpath and perform Click action but if element is available on Next page how can i do that ? I know i can find the xpath for next page and click it and look through it . But i want to come back to initial page as well.
For example I have 20 Elements found by xpath:
IList<IWebElement> Test= SeleniumDriver.WebDriver.FindElements(By.Xpath(""));
and if above will find 20 elements then i m running foreach loop. SO it can able to do all action as i needed but if first page got only 10 element then how can i go to next page for to find the remaining ones . Also in "Test" i'm not getting all the elements in order. So my foreach loop will find first 2 and might be 3rd one it tries to find will go to next page so i have to go to next page and find the element , validate it and then come back to initial page .
Please let me know if any easy way ?
You can write logic something like this
IList<IWebElement> Test= SeleniumDriver.WebDriver.FindElements(By.Xpath(""));
for each WebElement ele {
if(isElementPresent(ele) {
do Operation with ele
}
else {
go to second page
}
if(isElementPresent(ele)
do Operation with ele
Go to 1st page
}
If you have table with information you will have button to next page (if it exist)
so what you need to do is taking the elements like you did in while loop and check if next button exist if yes click on it and repeat taking the elements until button is exist
the best way is doing it by (pseudocode):
do
{
IList<IWebElement> Test= SeleniumDriver.WebDriver.FindElements(By.Xpath(""));
//HERE YOU CHECK IF BUTTON EXIST
if(isElementPresented(By.Id("")))
{
driver.FindElement(By.Id("")).Click;
}
else
{
//if button not exists
buttonExist = false;
}
}while(buttonExist);

Action on SharePoint New Item form in selenium 2 using C# is not working

I am trying to automate sharepoint site new item form but what ever method i try it is showing not found.
I tried switchTo() to a new iframe, window...
Tried this code which finds the outer content
IWebElement table1 = WebElement.FindElement(By.XPath("//table[#class=\"s4-wpTopTable\"]"));
int table1count = WebElement.FindElements(By.XPath("//table[#class=\"s4-wpTopTable\"]")).Count;
MessageBox.Show(table1count.ToString());
above code displays the table count as 2. Going beyond this element does not show any element.
And I am using IE as the browser.
I used Xpath and could identify till the red mark and it does not identify beyond that.. i am trying to identify the elements marked in green.
var iframecount = driver.FindElement(By.XPath("//html/body/form/div[8]/div/div[4]/div[2]/div[2]/div/div/table/tbody/tr/td
Here is the xpath is used taken from FireBug
var iframecount = driver.FindElement(By.XPath("//html/body/form/div[8]/div/div[4]/div[2]/div[2]/div/div/table/tbody/tr/td/div/span/table/tbody/tr/td[2]/span/span/input"));
i have found answer for this...
Sharepoint New item form (i.e modal pop up) has 3 iframes without id or name so switching to iframe using the below code works
driver.SwitchTo().Frame(2);
i.e frames start from 0 index.

Categories

Resources