Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Pavel Zakharov
/
Dispatch_Central
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 41c7c71a
authored
Mar 29, 2019
by
Igor Salmanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dsfsd
1 parent
903daf3c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
81 additions
and
30 deletions
CentralDispatcher/Program.cs
CentralDispatcher/Program.cs
View file @
41c7c71
...
...
@@ -18,53 +18,104 @@ namespace CentralDispatcher
private
static
readonly
string
titlePageUrl
=
"https://www.centraldispatch.com/"
;
private
static
readonly
string
userName
=
"Empo101"
;
private
static
readonly
string
password
=
"Miamiheat1"
;
private
static
readonly
string
findVehiclesUrl
=
"https://www.centraldispatch.com/protected/listing-search"
;
static
void
Main
(
string
[]
args
)
{
var
location
=
new
Uri
(
Assembly
.
GetEntryAssembly
().
GetName
().
CodeBase
);
var
chromedriverPath
=
new
FileInfo
(
location
.
AbsolutePath
).
Directory
.
ToString
();
// var options = new ChromeOptions();
// options.AddArguments("--headless", "--log-level=3", "--no-sandbox", "--disable-web-security", "--disable-gpu", "--incognito", "--hide-scrollbars");
// options.AddUserProfilePreference("profile.default_content_setting_values.images", 2);
var
location
=
new
Uri
(
Assembly
.
GetEntryAssembly
().
GetName
().
CodeBase
);
var
chromedriverPath
=
new
FileInfo
(
location
.
AbsolutePath
).
Directory
.
ToString
();
// using (
var
driver
=
new
ChromeDriver
(
chromedriverPath
);
var
windowSize
=
driver
.
Manage
().
Window
.
Size
;
// )
// {
driver
.
Navigate
().
GoToUrl
(
titlePageUrl
);
// using (
var
driver
=
new
ChromeDriver
(
chromedriverPath
);
// )
// {
driver
.
Navigate
().
GoToUrl
(
titlePageUrl
);
/*Actions action = new Actions(driver);
action.KeyDown(Keys.Control).SendKeys(Keys.F12).
KeyUp(Keys.Control).
Perform();*/
Actions
action
=
new
Actions
(
driver
);
action
.
KeyDown
(
Keys
.
Control
).
SendKeys
(
Keys
.
F12
).
KeyUp
(
Keys
.
Control
).
Perform
();
// find login button
var
loginBtn
=
driver
.
FindElementsByClassName
(
"loginBtn"
).
ToArray
()
.
Where
(
x
=>
x
.
Location
.
X
!=
0
&&
x
.
Location
.
Y
!=
0
).
FirstOrDefault
();
loginBtn
.
Click
();
var
btn
=
driver
.
FindElementsByClassName
(
"loginBtn"
).
ToArray
()
.
Where
(
x
=>
x
.
Location
.
X
!=
0
&&
x
.
Location
.
Y
!=
0
).
FirstOrDefault
();
// set user login and password
driver
.
FindElementById
(
"username"
).
SendKeys
(
userName
);
driver
.
FindElementById
(
"password"
).
SendKeys
(
password
);
btn
.
Click
();
// find login buttons array
var
submit
=
driver
.
FindElement
(
By
.
XPath
(
"//button[@type='submit'][text()='Login']"
));
submit
.
Click
();
var
email
=
driver
.
FindElementById
(
"username"
);
var
pass
=
driver
.
FindElementById
(
"password"
);
// push for authorization button
var
exp
=
driver
.
FindElementsByClassName
(
"loginBtn"
).
ToArray
(
);
email
.
SendKeys
(
userName
);
pass
.
SendKeys
(
password
);
// redirect to find vehicles page
driver
.
Navigate
().
GoToUrl
(
findVehiclesUrl
);
var
submit
=
driver
.
FindElement
(
By
.
XPath
(
"//button[@type='submit'][text()='Login']"
));
submit
.
Click
();
// find area originRegion
var
originRegion
=
driver
.
FindElementByName
(
"origin[region]"
);
var
selectOriginRegionElementAll
=
new
SelectElement
(
originRegion
);
selectOriginRegionElementAll
.
SelectByValue
(
"All"
);
var
exp
=
driver
.
FindElementsByClassName
(
"loginBtn"
).
ToArray
();
// var findItem = driver.FindElement(By.Id("navSearchVehicles"));
// findItem.Click();
driver
.
Navigate
().
GoToUrl
(
"https://www.centraldispatch.com/protected/listing-search"
);
var
originRegion
=
driver
.
FindElementByName
(
"origin[region]"
);
var
selectOriginRegionElementAll
=
new
SelectElement
(
originRegion
);
selectOriginRegionElementAll
.
SelectByValue
(
"All"
);
// find region area destinationRegion
var
destinationRegion
=
driver
.
FindElementByName
(
"destination[region]"
);
// select "All" item
var
selectDestinationRegionElementAll
=
new
SelectElement
(
destinationRegion
);
selectDestinationRegionElementAll
.
SelectByValue
(
"All"
);
;
// open area date and pricing options
var
dateAndPricingOptions
=
driver
.
FindElementById
(
"page-date-pricing-chev"
);
dateAndPricingOptions
.
Click
();
// open list "readyToShip" items
driver
.
Manage
().
Window
.
Size
=
new
System
.
Drawing
.
Size
(
100
,
900
);
var
readyToShip
=
driver
.
FindElementById
(
"readyToShip"
);
readyToShip
.
Click
();
driver
.
Manage
().
Window
.
Size
=
new
System
.
Drawing
.
Size
(
windowSize
.
Width
,
windowSize
.
Height
);
// select "14 Days" item
// open list "paymentType" items
var
paymentType
=
driver
.
FindElementById
(
"paymentType"
);
// paymentType.Click();
// select "All" item
var
paymentTypeAll
=
new
SelectElement
(
paymentType
);
var
optionTypeAll
=
paymentTypeAll
.
Options
.
Where
(
x
=>
x
.
Text
==
"All"
).
First
();
optionTypeAll
.
Click
();
//paymentTypeAll.SelectByValue("All");
var
readyToShipWithin
=
new
SelectElement
(
readyToShip
);
// readyToShipWithin.SelectByValue("60 Days");
var
optionReadyToShipWithin
=
readyToShipWithin
.
Options
.
Where
(
x
=>
x
.
Text
==
"14 Days"
).
First
();
optionReadyToShipWithin
.
Click
();
// open area date and pricing options
var
pageResultOptions
=
driver
.
FindElementById
(
"page-results-options-chev"
);
pageResultOptions
.
Click
();
// open area cargo options
driver
.
Manage
().
Window
.
Size
=
new
System
.
Drawing
.
Size
(
100
,
900
);
var
vehicleOptions
=
driver
.
FindElementById
(
"page-vehicle-spec-chev"
);
vehicleOptions
.
Click
();
driver
.
Manage
().
Window
.
Size
=
new
System
.
Drawing
.
Size
(
windowSize
.
Width
,
windowSize
.
Height
);
var
body_html
=
driver
.
PageSource
;
// }
}
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment