I am using this site - https://www.blueshieldca.com/home - and click on 'Find a Provider'. In the Located Near input I am typing 'los' and I have to select the second value from suggested options.
Can any one please tell me how to write xpath for it?
A simple approach would be with explicit wait.
new WebDriverWait(driver,30).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//li[#class='ui-menu-item'][2]"))).click();
Use this //li[#class='ui-menu-item'][#role='menuitem'] [2]
You site is not working. please post the HTML and try with this:
//Select option last activity as Completed
WebElement select = driver.findElement(By.name("status"));
List<WebElement> options = select.findElements(By.tagName("option"));
for(WebElement option : options){
if(option.getText().equals("Confirmed")) {
option.click();
break;
}
}
I have most of it working. The problem I faced here is that it is not selecting the second value from the drop down..
IWebDriver driver = new FirefoxDriver();
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
driver.Navigate().GoToUrl("https://www.blueshieldca.com/home");
driver.Manage().Window.Maximize();
driver.FindElement(By.XPath("//div[contains(#class,'primary_navigation_area')]//li[4]//a[contains(#onclick,'dcsMultiTrack')]")).Click();
IWebElement entercity = driver.FindElement(By.Id("location"));
entercity.Click();
entercity.SendKeys("los");
wait.Until((d)=>driver.FindElement(By.XPath("//li[#class='ui-menu-item'][#role='menuitem'][2]")));
driver.FindElement(By.XPath("//li[#class='ui-menu-item'][#role='menuitem'][2]")).Click();
driver.FindElement(By.ClassName("findNow")).Click();
Related
I am trying to automate Windows app using Win app driver, How can we select item from the list using java?
WindowsElement comboBoxElement1= (WindowsElement) DesktopSession.findElementsByXPath("//List[#Name='Select Outlet:']//*[starts-with(#AutomationId,'listBox')]");
comboBoxElement1.findElementByName("!xyz").click();
I am getting error as not being able to locate the element. Also most of the cases findElementByXpath is not working.
UI looks as below:
use sendkeys:
comboBoxElement1.SendKeys("name of the item");
UPDATE
comboBox.Click();
string xPathListItem = $"//Text[contains(#Name, '{dateTom}')]/preceding::Custom[1]/ComboBox/ListItem[1]"; //xPath of your item in combobox
elem = (WindowsElement)window.FindElementByXPath(xPathListItem);
app.DoubleClick(elem);
here is my DoubleClick method:
public void DoubleClick(WindowsElement elem)
{
session.Mouse.MouseMove(elem.Coordinates);
session.Mouse.DoubleClick(null);
}
I am getting error of NoSuchWindowException with this code.I am unable to switch back to old opened window and get back to new window
please review my code and help me.
public void TC_123617()throws InterruptedException {
driver.findElement(By.id("user_login")).sendKeys("akhil");
driver.findElement(By.id("user_pass")).sendKeys("akhil");
driver.findElement(By.id("wp-submit")).click();
Thread.sleep(3000);
driver.findElement(By.cssSelector("#awebsome_oruw-2 > ul")).click();
WebElement userStatus = driver.findElement(By.xpath(".//*[#id='awebsome_oruw-2']/ul/li[11]"));
String parentWindow = driver.getWindowHandle();
driver = new FirefoxDriver();
driver .manage().window().maximize();
driver.get("http://103.16.143.96/incis/wp-login.php");
driver.findElement(By.id("user_login")).sendKeys("manager");
driver.findElement(By.id("user_pass")).sendKeys("manager");
driver.findElement(By.id("wp-submit")).click();
for (String popUpHandle : driver.getWindowHandles()) {
if(!popUpHandle.equals(parentWindow)){
driver.switchTo().window(popUpHandle);
driver.switchTo().window(parentWindow);
}
}
}
You don't need to create a new driver instance if you want to switch between windows using driver.
Save a reference to current window. (so that you can return to perform actions on the window you started from.)
String parentWindow = driver.getWindowHandle();
Next Step, get all the windows and switch to the new window.
List<String> allWindows = driver.getWindowHandles();
for(String curWindow : allWindows){
driver.switchTo().window(curWindow);
}
Now, you can perform any action on the new window, and when done you could close it using
driver.close();
Finally, you can switch back to the parent window to continue your actions using
driver.switchTo().window(parentWindow)
I am using the local database example taht Microsoft created.
I can add items to the list, and delete them. But I now want to select the items and get the text of the item and use that in the next page.
This is the select changed event:
private void allToDoItemsListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
NavigationService.Navigate(new Uri("/LiveTimes.xaml?selectedItem=" + allToDoItemsListBox.SelectedIndex, UriKind.Relative));
// string urlWIthData = string.Format("/LiveTimes.xaml?name={0}", " ");
// this.NavigationService.Navigate(new Uri(urlWIthData, UriKind.Relative));
}
Then this is the on page load on the other page.
string selectedIndex = "";
if (NavigationContext.QueryString.TryGetValue("selectedItem", out selectedIndex))
{
int index = int.Parse(selectedIndex);
DataContext = App.ViewModel.HomeToDoItems[index];
}
Then when i use this, the error is on the DataContext line.
Whats the solution?
There is no problem in the above code that you have shown, The actual problem may be in the way how you defined your ViewModel and HomeToDoItems . It helps us to solve your problem, if you can show some of that code.
Also before setting your data to DataContext, try the following steps:
First, make sure you are getting the valid selectedIndex.
var tempData = App.ViewModel.HomeToDoItems[index];
DataContext = tempData;
And then insert a break point at tempData to check whether you are getting the expected data.
This answer may not solve your problem, but guide you in identifying the actual problem.
After quite a lot of debugging, I've refined a complicated Managed EWS problem down to the following two simple-ish test cases. The first one works, the second one fails:
var view = new ItemView(100) { PropertySet = new PropertySet { EmailMessageSchema.Id } };
var findResults = ews.FindItems(WellKnownFolderName.Inbox, view)
var bindResults = ews.BindToItems(findResults.Select(r => r.Id), new PropertySet { EmailMessageSchema.Sender });
// Sanity check
Assert.AreEqual(1, bindResults.Count());
// The results I care about
Assert.AreEqual("David Seiler", bindResults[0].Sender.Name);
Assert.AreEqual("david.seiler#yahoo.com", bindResults[0].Sender.Address);
One might try to cut out the BindToItems() call, and use FindItems() directly:
var view = new ItemView(100) { PropertySet = new PropertySet { EmailMessageSchema.Sender } };
var findResults = ews.FindItems(WellKnownFolderName.Inbox, view)
// This part still works fine
Assert.AreEqual(1, findResults.Count());
// So does this
Assert.AreEqual("David Seiler", findResults[0].Sender.Name);
// ...but this fails! Sender.Address is null
Assert.AreEqual("david.seiler#yahoo.com", findResults[0].Sender.Address);
Can anyone tell me where I've gone wrong? It really seems, from the documentation, as though this should work. Not all properties can be read through FindItems(), it's true, but those properties usually throw when I try to access them, and anyway there's a list of those properties on MSDN and Sender isn't on it. What's going on?
Actually I don't know why, but in the second option, it only load basic information of the sender like the name, but not the Address.
If you want to load all the sender properties but do not want to bind the full message you can add the following line before the first assert
service.LoadPropertiesForItems(findResults.Items, new PropertySet(EmailMessageSchema.Sender));
I am using Sap Crystal Report in asp.net 2010
It will shows the error no valid report source id available, when i refreshing the report or moving to next page at run time using report viewer tools
and this is my coding,
Dim crdoc5 As New ReportDocument()
Dim crtablogoninfo5 As New TableLogOnInfo
Dim crtabs5 As Tables
If Not IsPostBack Then
crdoc5.Load(Server.MapPath("CrStaffrecruit.rpt"))
Session.Add("CrStaffrecruit", crdoc5)
CrystalReportViewer5.ReportSource = crdoc5
Else
CrystalReportViewer5.ReportSource = Session("CrStaffrecruit")
End If
crdoc5.Load(Server.MapPath("CrStaffrecruit.rpt"))
Dim crconninfo5 As New ConnectionInfo()
rconninfo5.ServerName = "servername"
crconninfo5.DatabaseName = "databasename"
crconninfo5.UserID = "sa"
crconninfo5.Password = ""
crtabs5 = crdoc5.Database.Tables()
For Each crtab5 As CrystalDecisions.CrystalReports.Engine.Table In crtabs5
crtablogoninfo5 = crtab5.LogOnInfo
crtablogoninfo5.ConnectionInfo = crconninfo5
crtab5.ApplyLogOnInfo(crtablogoninfo5)
Next
CrystalReportViewer5.ReportSource = crdoc5
CrystalReportViewer5.RefreshReport()
If any one know pls help me...
Thanks in advance
For this please go through the following link
http://forums.sdn.sap.com/thread.jspa?messageID=10951477�
Although the following code is in C#, it shouldn't be too difficult to translate it to VB and it should solve your issue:
protected void Page_Load(object sender, EventArgs e)
{
if (Page.IsPostBack)
{
//whatever you do when the page is loaded for the first time
//this could even be bindReport();
}
else
{
bindReport();
}
}
public void bindReport()
{
ReportDocument rptDoc = new ReportDocument();
dsSample ds = new dsSample(); // .xsd file name
DataTable dt = new DataTable();
// Just set the name of data table
dt.TableName = "Crystal Report Example";
dt = getMostDialledNumbers(); //This function populates the DataTable
ds.Tables[0].Merge(dt, true, MissingSchemaAction.Ignore);
// Your .rpt file path will be below
rptDoc.Load(Server.MapPath("yourReportFilePath.rpt"));
//set dataset to the report viewer.
rptDoc.SetDataSource(ds);
CrystalReportViewer1.ReportSource = rptDoc;
CrystalReportViewer1.RefreshReport();
//in case you have an UpdatePanel in your page, it needs to be updated
UpdatePanel1.Update();
}
I was experiencing the same problem. In what event are you executing the code you posted? I ask because after much debugging, I discovered that you need to place the code in Page_Load (as opposed to PreRender like I was doing previously...)
Hope this helps.
I have got this problem several times, and the solution is to save the Report Document variable in a session then in the Page_load put the below code:
if (IsPostBack)
{
if (Session["reportDocument"] != null)
{
ReportDocument cr = new ReportDocument();
cr = (ReportDocument)Session["reportDocument"];
CrystalReportViewer1.ReportSource = cr;
CrystalReportViewer1.DataBind();
}
}
NB:
Don't forget to fill the (Session["reportDocument"]) with the Display button.
Go through following link. I resolved same issue with that solution.
http://www.aspsnippets.com/Articles/ASPNet-Crystal-Reports-13-Visual-Studio-2010-CrystalReportViewer-Search-Button-Issue---No-valid-report-source-is-available.aspx